-
Notifications
You must be signed in to change notification settings - Fork 92
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
Requests stuck in a pending state when using a Interceptor and node 14 #67
Comments
By direct request in the address bar http://localhost:3000/_next/static/chunks/main.js?ts=1605799518477 the file is successfully loaded |
This link has a similar problem https://stackoverflow.com/questions/63610932/express-static-network-requests-stuck-on-pending |
have you tried checking if it works correctly on node 12? |
@kyle-mccarthy Yes, in the description of the issue I wrote:
This is a minimal version of the project with a reproduced issue: https://github.com/DiFuks/nest-next-minimal For a successful run:
or
For an unsuccessful run:
|
Perhaps the problem is not with your library, but for example with express. But first I would like to make sure of this |
This hard fix worked for me: https://github.com/DiFuks/nest-next-minimal/commit/e8fb00c503ac65f3fbfc24d402cc8d47b79a9f1c |
Okay I've spent the better part of the last 2 days debugging this and think I have an idea of what's going on. However, I'm not entirely sure what is responsible for the problem. The primary thing is that the interceptor seems to be causing the next incoming http request to hang. You can verify this by using node14 and the I suspect that the problem is caused by (a) changes to the event loop in node 14 or (b) changes to ending or closing the http response. The reason that I think this is that I can actually make the interceptor work by forcing the
By making the map function return the promise which requires an extra tick to resolve it keeps the the next request from hanging. I actually suspect that by using Let me know what you think, I do think that this is an upstream issue unrelated to this repo but nonetheless is pretty interesting. |
This solution works for me. But I don't understand why response.render is returning a promise. |
I'm afraid my knowledge of node.js and English is not deep enough to correctly formulate the problem. 😅 |
The response.render is returning a promise because it is actually calling next's render function instead of the express render function. This library overrides the default render function provided by express with next's render function. This is primarily done to allow for devs to easily render without directly using the I am not exactly sure of the best path forward since there are many different package at play (this one, next, nest, express, etc..) so it's difficult to determine what's responsible for the change. For instance, it could be that node 14 is a little faster than node 12 exposing the race condition. If this is something that you want to dive deeper into, you will probably want to use node's debugger and isolate differences between how v12 and v14 handle the problematic request. |
After a request to the address http://localhost:3000/ the server serves all files except one. This file gets stuck in "pending" status. IMPORTANT! The bug is only seen in 14+ versions of node.js. There is no error in version 12:
The text was updated successfully, but these errors were encountered: