Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
[v13.x backport] zlib: align with streams#32371
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,29 @@ | ||
| 'use strict'; | ||
| require('../common'); | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const zlib = require('zlib'); | ||
| // Verify that the zlib transform does clean up | ||
| // the handle when calling destroy. | ||
| const ts = zlib.createGzip(); | ||
| ts.destroy(); | ||
| assert.strictEqual(ts._handle, null); | ||
| { | ||
| const ts = zlib.createGzip(); | ||
| ts.destroy(); | ||
| assert.strictEqual(ts._handle, null); | ||
| ts.on('close', common.mustCall()); | ||
| } | ||
| { | ||
| // Ensure 'error' is only emitted once. | ||
| const decompress = zlib.createGunzip(15); | ||
| decompress.on('error', common.mustCall((err) => { | ||
| decompress.close(); | ||
| })); | ||
| decompress.write('something invalid'); | ||
| decompress.destroy(new Error('asd')); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,7 +5,9 @@ const assert = require('assert'); | ||
| const { Gunzip } = require('zlib'); | ||
| const gunzip = new Gunzip({ objectMode: true }); | ||
| assert.throws( | ||
| () => gunzip.write({}), | ||
| TypeError | ||
| ); | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little unsure how exactly this could throw before. | ||
| gunzip.write({}, (err) => { | ||
| assert.strictEqual(err.code, 'ERR_INVALID_ARG_TYPE'); | ||
| }); | ||
| gunzip.on('error', (err) => { | ||
| assert.strictEqual(err.code, 'ERR_INVALID_ARG_TYPE'); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,12 +27,7 @@ const zlib = require('zlib'); | ||
| zlib.gzip('hello', common.mustCall(function(err, out) { | ||
| const unzip = zlib.createGunzip(); | ||
| unzip.close(common.mustCall()); | ||
| assert.throws( | ||
| () => unzip.write(out), | ||
| { | ||
| code: 'ERR_STREAM_DESTROYED', | ||
| name: 'Error', | ||
| message: 'Cannot call write after a stream was destroyed' | ||
| } | ||
| ); | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little unsure how exactly this could throw before. | ||
| unzip.write(out, (err) => { | ||
| assert.strict(err.code, 'ERR_STREAM_DESTROYED'); | ||
| }); | ||
| })); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finisheddoes not invoke callback on closed stream, this was a semver-major fix does not land on 13