-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Uncaught TypeError using http.Agent in keep-alive mode #8650
Comments
@mscdex would you reconsider
is the one actually making the failing doWrite(stream, state, true, state.length, buffer, '', holder.finish); and by looks of it the
|
If there's any way I can grab extra information about the error, I will be happy to do so. I'm not experienced debugging Node internals, so I might need guidance. I added a delay before the call that consistently fails, and this doesn't seem to prevent it from failing, which I guess means that it's not a timing issue as much as an order-of-operations issue. |
Try https://www.npmjs.com/package/longjohn, it will give you long stack traces. |
|
Also, I noticed that I noted that you've manually provided custom agent object for the client with Just to be sure, I'd avoid using This could be nothing, but maybe worth a check? |
@imyller I'm using dynalite to mock DynamoDB for the service-level tests, and I've already verified with tcpdump that no HTTPS connections are even being attempted, so I don't think HTTP/HTTPS confusion in the AWS SDK is the issue. I've run a test using longjohn and the given NODE_DEBUG environment variable. The output is immense; should I pastebin the whole thing or post it here, and should I try to pare it down a bit to (what I think are) just the relevant bits? |
Excellent that you've verified that. In theory, that had potential to cause unexpected behaviour.
Pastebin or GitHub Gist are both ok for me. Sometimes the things that first seem irrelevant are indeed the most valuable. We can pick the relevant shorter snippets from there to this discussion if needed. |
Here's the exception trace. I'll get the NODE_DEBUG output later today. https://gist.github.com/cdhowie/515b97824b49660a60f9d535077070f0 |
I updated the gist with the debug info. (Sorry for the delay, been busy with this project!) This test is the one that fails. I assume that whatever went wrong did so right before this line. This prior test succeeds, so I guess we're looking somewhere between these two lines to start with? The test that fails makes several successful HTTP requests before making the one that consistently fails with this "object is not a function" error. |
Hi @imyller @bnoordhuis , @EladBezalel reported an issue really similar to this one. He created a isolated example: chimurai/http-proxy-middleware#39 (comment) Hope this will be helpful in pinpointing the problem. |
@chimurai You wouldn't happen to have a test case that only uses built-in modules? |
@bac42x until i can find a solution for that i dropped the use of |
Has anyone managed to replicate this using just Node.js and not external modules? If so, a gist or something would be useful. |
@Trott do you mean without any http modules? I also tried without http-proxy-middleware and did my own express server to proxy the requests, still not working |
I mean using only Node.js and internal modules. So no |
The test that usually failed due to this issue is not failing as of v6.11.2. I'm still hesitant to turn this on in production due to the unpredictable nature of the issue. @EladBezalel What Node version are you using? |
@cdhowie that was long time ago, so i assume some version of node 6 |
Do you still experience this issue? I've tried numerous things and for the life of me I can't get it to happen as of v6.11.2. |
This is the same issue as this one I filed against aws-sdk-js, but I'm getting more suspicious that this is actually a Node issue.
Configuration example:
After some number of HTTP requests (a few dozen) using an
http.Agent
constructed withkeepAlive: true
, the following uncaught error occurs:Digging into the Node code, this hints that the callback supplied to a
net.Socket.write()
call was omitted, but the documentation states this callback is optional. In either case, changingkeepAlive: true
tokeepAlive: false
when constructing thehttp.Agent
eliminates the error.I do not make any HTTP calls myself, only via the AWS SDK. I can't find any obvious bug in my code; I'm just making AWS DynamoDB calls using their SDK. Since the call stack for the error is all Node internals, I do not have any opportunity to properly catch the error; the process simply dies.
The error consistently happens on one particular test. If I comment out a particular request in that test, then a future test (which does something entirely different) will fail instead. The fact that the test passes when not using keep-alive suggests to me that there is some kind of timing issue somewhere else.
The text was updated successfully, but these errors were encountered: