-
Notifications
You must be signed in to change notification settings - Fork 195
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
Error [ERR_MULTIPLE_CALLBACK]: Callback called multiple times #369
Comments
I also see this issue when using spdy in an Express.js app that uses an async pattern in one of its request handlers. ryanoshea/ryanoshea.com#31. It only happens on Node v12, but not v10. |
This happens to me when sending files using express on node v13 |
I am facing the same issue when upgrading nodejs from v10.15.3 to v12.17.0 -lts, wanted to open a same issue...
If someone needs a POC, I can create a github repo to reproduce. |
Hi, I too have the same problem. ` _stream_writable.js:475 Error [ERR_MULTIPLE_CALLBACK]: Callback called multiple times |
Hi, I created the POC, and also found a fix to the library |
@hotyhuang I'm trying your modification and it seems to work !!!
|
@hotyhuang ,
|
Hi @gaxolio ,
|
Hi @hotyhuang , I can't reproduce the problem systematically. In short here are the steps for each stream(4): 1 - app.get('/streams/x', function(req, res) {... Occasionally the error appears when sending an event, nodejs no longer responds and I have to restart it. It does not end with an error. |
@gaxolio I cannot get the error as you've mentioned, everything looks fine with the fix.... Created a repo by sse-channel, maybe you can help decorate this repo, to reproduce the issue: |
I am also facing this issue randomly on canceled requests (Node v.12.18.3), but with the "fix" I always get the following error when trying to do a file upload: TypeError: this._handle.readStop is not a function |
Having only done a small bit of digging, it seems like a perfect storm of outright incompatibility with the HTTP/2 spec, upgrades in core node, hacks (sorry, polyfills? ponyfills? whatever it is now), and the now-outdated protocol of SPDY, combined with the fact that this package is no longer maintained for the reasons mentioned above... For better or worse, this is the solution I found for now (still need to dig further): Throw this
All that said, migrate your stuff to the native http2 (in v12+) module (e.g. Edit: Ended up reverting to core https module instead of spdy as the above hack is not entirely reliable. |
@aphix are you sure it's safe to just swallow the error? I thought this was always a no-no. As for the http2 migration, it will be done the minute the express.js folks finally release proper support for the native implementation (if that ever happens)... |
Every couple of years I come back to this project thinking surely they’ve added support for it and so far that hasn’t worked. |
@nemphys looking at the stack traces & profiles/flamegraphs, the same error was already thrown and caught as expected, which is what tears down the inflight req in the first place, but you're right that eating unexpected errors is generally not good, however I'd consider this one expected (if somewhat random in terms of reproducibility) at this point. Definitely log it (as seen in the snippet) and rethrow anything else you don't expect (as in the snippet), and if you wish to restrict it further you could make sure the string/stack trace has "handle-thing" in it or something, but that seemed like a potential maintenance nightmare to me, as timing when the 2nd cb is hit could likely change the stacktrace. This is really a bandaid to prevent that specific error from tearing down your whole server. Note that it's far less likely to happen between two servers/applications than it is between a server and a browser client, at least. I've actually yet to see this happen in any server-server reqs over a few million transactions during this past week, but can trigger it manually with a browser spamming refresh quite easily. |
Following up after more testing yesterday: There's some gnarly hack in stream_readable that force prepends its listener to uncaught exceptions as a fix for older node versions, but does not validate that the running version needs the hack before doing so, meaning that my above fix may not work in all cases so I reverted to using the native https module as I wasn't getting any benefit from HTTP/2 methods like req.push since I'm behind an AWS ALB anyway. Good luck to others, but I've given up on getting spdy to work reliably in v12 for the time being. |
The same issue troubled me recently. Found that upgrading node.js from |
Hi @JoshOY . Please could you confirm that after the upgrading to |
Hi @gaxolio , The background is that we are proxying https requests with an framework based on |
Hi @JoshOY , thanks for your support. |
Glad to help! You're welcome :-) |
how to reproduce: send a video to a browser and while it is loading (and playing) the video reload the page
The text was updated successfully, but these errors were encountered: