-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Closing zlib stream may throw uncaught exception #15625
Comments
Sounds like it may be a good idea to attach an appropriate cc @nodejs/streams as there could still be an issue in here |
Adding an That said, even if the error listener would work, there is still a bug here - closing a stream should not emit an error either. |
I think this is fixed in 8: https://github.com/nodejs/node/blob/master/lib/zlib.js#L465-L484 vs https://github.com/nodejs/node/blob/v6.x/lib/zlib.js#L622-L643. The PR is #13322, but that's not easily backportable, so we might want to do an ad-hoc fix for Node 6. |
True, this seems fixed in 8. Would need testing to be sure, but unfortunately switching to 8 would be really difficult. FWIW: We are currently testing |
I can definitely confirm that using |
@nakedible-p would you like to send a PR? |
@nakedible-p we are putting out an r.c. for the next 6.x today. If you can get a PR in within the next week we can get it in a future RC before the release |
I can do a fix PR for certain, but I have no idea how I would write a testcase for this. If a simple fix is fine, I'll get it done right away. |
@MylesBorins @mcollina There is now an extremely minimal fix PR. Let me know what else should I do. |
Closing a zlib stream may throw an uncaught exception afterwards if there was a pending callback still to be invoked. This adds a very minimal fix to the issue as all of this code has been rewritten in later versions. Fixes: nodejs#15625
Closing a zlib stream may throw an uncaught exception afterwards if there was a pending callback still to be invoked. This adds a very minimal fix to the issue as all of this code has been rewritten in later versions. Fixes: #15625 PR-URL: #16312 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Closing a zlib stream may throw an uncaught exception afterwards if there was a pending callback still to be invoked. This adds a very minimal fix to the issue as all of this code has been rewritten in later versions. Fixes: #15625 PR-URL: #16312 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Looks like this was resolved in #16312 — no clue why it didn't autoclose. |
When calling
.close()
on azlib.createGunzip()
stream while the engine is still working on decompressing some stuff, sometimes this exception is thrown:Looking at the code, it seems that when
_processChunk
sets a callback, it does not sufficiently check thatthis._handle
has not been unset in the meantime. The earlier code hasassert(this._handle, 'zlib binding closed');
check, but the callback code does not.But even the assert is wrong, as calling
.close()
on a stream, even when there's unprocessed data, should not throw any exceptions. I guess the function should check forthis._closed
similarily as it checks forthis._hadError
currently.Unfortunately this bug is triggered very rarely on a production system, so I haven't been able to write short code to reproduce the issue.
The text was updated successfully, but these errors were encountered: