New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[next.config.js rewrites] Error: socket hang up #36251
Comments
+1 for a resolution to this issue. being able to customize the timeout would be nice. also it'd be nice to show an error message that's less cryptic when a timeout happens. it's not obvious that this error is caused by a hardcoded 30-second timeout in the http proxy config used by next.js rewrites:
|
Same issue here! |
1 similar comment
Same issue here! |
same here
|
Same error, error - unhandledRejection: Error: aborted
at connResetException (node:internal/errors:691:14)
at abortIncoming (node:_http_server:596:17)
at socketOnClose (node:_http_server:590:3)
at Socket.emit (node:events:402:35)
at TCP.<anonymous> (node:net:672:12) {
code: 'ECONNRESET'
} |
Same issue with node 14.18 |
Same error... error - unhandledRejection: Error: aborted
at connResetException (node:internal/errors:691:14)
at abortIncoming (node:_http_server:596:17)
at socketOnClose (node:_http_server:590:3)
at Socket.emit (node:events:402:35)
at TCP.<anonymous> (node:net:672:12) {
code: 'ECONNRESET'
} |
error - unhandledRejection: Error: aborted
at connResetException (node:internal/errors:691:14)
at abortIncoming (node:_http_server:596:17)
at socketOnClose (node:_http_server:590:3)
at Socket.emit (node:events:402:35)
at TCP.<anonymous> (node:net:687:12) {
code: 'ECONNRESET'
} same with node v16 and next latest (not canary) in windows machine |
|
error - unhandledRejection: Error: aborted |
To add some additional details, this is happening to me sporadically without any rewrites off latest (12.2.3). I can try canary later today. It's sporadic, but I'm more likely to see it right after server start. And it is happening to me in production. I saw it some Sentry logs this morning. Hope some of this helps |
It seems like with the latest NextJS version now it also leads to memory leaks. I can see that my NextJS app keeps failing due to allocation failure.
|
Same here : error - unhandledRejection: Error: aborted |
Hi, the |
@ijjk are there any plans for the near future to look into rewrites related issue? |
The initial issue appears to be related to the timeout with proxying to external resources which can be seen here next.js/packages/next/server/next-server.ts Line 517 in a818606
Potentially this timeout could be configurable via an experimental config. |
same here . This issue is causing error in build ☹ error - unhandledRejection: Error: aborted |
Joining the club: This is occuring when I add in a getStaticProps function, even if the function doesn't call any outside data. Very strange.
|
Similar issue over here. If I try to open the page right after started the local server, I encounter the following error:
If I wait for the page build, then open the page: no error. |
Hi, can you please confirm you are still seeing this error on the latest canary of Next.js |
@ijjk Thanks for your response. I just installed |
error - unhandledRejection: Error: aborted Here too, using useEffect to call google api. |
In my case, I installed canary-8 version and no error log occurred. |
The latest release is still in 12.2.3. we need to wait for the 12.2.4 in order the fix to be applied in latest release |
Just tried with 12.2.4-canary.8 and the issue is still there. Logs: |
I doubt this is what's causing most peoples issues...but the fix for me was that in my function in my api folder it was using 'return data' instead of 'res.status(200).json(data)'.
Once I sorted that, my API call in getStaticProps() worked fine and the error went away. |
I don't think so because i have freshly created new project still it's showing me that error very strange 🤔. |
It's strange but it worked for me ! |
To solve this error log, I installed canary.8 version and confirmed that the log does not appear anymore. However, when I checked the source modified in the canary version, if my thinking was correct, I understood that the log was prevented from occurring directly in the terminal by catching the error in the 'Promise' part of the existing bodyStream area. It was simply that the log was not visible, and the actual log was continuously occurring. Fortunately, the server didn't die and worked normally. I spent several days analyzing the cause of the error. What the logs have in common is a TCP error and an ECONNRESET phenomenon where the socket is disconnected. There are several causes of ECONNRESET errors, but I thought that one of the main ones had to do with forcing the server to kill requests for excessive requests. However, in my case, the above error was discovered when parallel processing in the page and a large number of API requests in the page were added. There was no problem with the response to the API request, but there were repeated requests that I did not know about on the server side. And after finding the cause and solving that part, I went back to the current release version and checked if the same error log occurs again, but the error does not occur anymore. If you get a normal response when making a normal API call, you can think of it as no problem, but there seems to be a case where the actual request API sends the result to send a repeated request to our server. I'm a front-end developer, so I didn't know the actual server area in detail, and I always paid attention to the normal request and response part. This was my case. In a way, I think this error log happened to me and eventually helped me to optimize my project. Thanks, I think this error log really helped me. |
@youzooyou What do you mean when saying API calls? Is it about Next.js API endpoints (/pages/api/*), or those calls that your application is making from its server-side? |
@johnb0 Sorry for writing too long an answer here. My case was about Rest API calls from server side. In my project, there are two APIs that need to be called from the server side in common, and these are processed as Promise.all and additionally, one server-side API call for setting initialData is made. In addition, we make 5 client-side API calls. In the case of the above error, it started to occur as the completeness of the page increased. I'm not sure why others got the same error, but in my case it was the nextjs server's response to an internal value handled by the server, rather than the simple response value that the target API responds to when calling the API. It wasn't the wrong answer. Naturally, it was a normal event in a server-to-server conversation, and this was an error for me. In nextjs, we dealt with these errors through exception handling so that the server does not die. It's really great. Even if I call the Rest API of another domain or an api that works directly from /pages/apis/*, even if I request a response from another server there, my nextjs server sends a response based on unknown information sent by the response server. This means that in the process of processing it, you may be sending invalid or repeated requests. In the response of the normal 200 status value, there was a case where there was a problem with the request or the other server sent additional event information due to incorrect authentication processing at the time of the request. For anyone else, if this kind of error occurred on a page without an API call, it could be serious, but in my case it was elsewhere. In other words, it was a phenomenon in which the socket connection was disconnected due to repeated requests from the unknown server side and the number of requests exceeded. If you suspect the same case as me, it would be good to monitor and debug the entire response object, not the { data } we use, among the data returned from the server side. |
hi, is there any solution to fix this? |
I think we should wait since the canary version (next@12.2.4-canary.9) is fine. |
what's up this one ? |
this issue could be fixed with a nginx configuration if you have something like this:
you proxy with this ...
In this way know you have control of the timeout |
Guys did you fix the issue? I have the same problem. If someone knows, how to fix it, I'll be really apreciate :) |
Okay, to solve this just: npm install next@12 |
Just wait for next |
I noticed strange thing, when I disable keepAlive (https://nextjs.org/docs/api-reference/next.config.js/disabling-http-keep-alive) the error goes away. Unfortunately it has negative impact on response time under high load |
<!-- Thanks for opening a PR! Your contribution is much appreciated. In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change that you're making: --> ## Bug - [X] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Fixes #36251
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using rewrites it's impossible to make a request to API endpoint that takes more than 30 seconds to respond. After 31 second Next just throws the error
Server Error Error: socket hang up
which makes it impossible to use with any responding APIs.Expected Behavior
There should be a soft timeout which would not throw after 30 seconds but should proceed waiting for the response and only show a warning. Or provide additional option to set custom timeouts.
To Reproduce
Create a rewrite rule to the endpoint which responds more than 30 seconds.
The text was updated successfully, but these errors were encountered: