-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
stream: disallow writing string chunk with 'buffer' encoding #63062
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ function test(autoDestroy) { | |
| { | ||
| const w = new Writable({ | ||
| autoDestroy, | ||
| _write() {} | ||
| write() {} | ||
|
Member
Author
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. These tests were using the wrong constructor option name for setting the |
||
| }); | ||
| w.end(); | ||
| expectError(w, ['asd'], 'ERR_STREAM_WRITE_AFTER_END'); | ||
|
|
@@ -40,34 +40,42 @@ function test(autoDestroy) { | |
| { | ||
| const w = new Writable({ | ||
| autoDestroy, | ||
| _write() {} | ||
| write() {} | ||
| }); | ||
| w.destroy(); | ||
| } | ||
|
|
||
| { | ||
| const w = new Writable({ | ||
| autoDestroy, | ||
| _write() {} | ||
| write() {} | ||
| }); | ||
| expectError(w, [null], 'ERR_STREAM_NULL_VALUES', true); | ||
| } | ||
|
|
||
| { | ||
| const w = new Writable({ | ||
| autoDestroy, | ||
| _write() {} | ||
| write() {} | ||
| }); | ||
| expectError(w, [{}], 'ERR_INVALID_ARG_TYPE', true); | ||
| } | ||
|
|
||
| { | ||
| const w = new Writable({ | ||
| decodeStrings: false, | ||
| autoDestroy, | ||
| _write() {} | ||
| write() {} | ||
| }); | ||
| expectError(w, ['asd', 'buffer'], 'ERR_UNKNOWN_ENCODING', true); | ||
| } | ||
|
|
||
| { | ||
| const w = new Writable({ | ||
| autoDestroy, | ||
| decodeStrings: false, | ||
| write() {} | ||
| }); | ||
| expectError(w, ['asd', 'noencoding'], 'ERR_UNKNOWN_ENCODING', true); | ||
| expectError(w, ['asd', 'buffer'], 'ERR_UNKNOWN_ENCODING', true); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This was a test for the behaviour reported in #12152, where calling
.write('string', 'buffer')on a StreamBase-backed stream would crash the process. I don't believe there's any way to hit this if this change lands, but not confidently enough to revert back to a CHECK (cf. #12753) without a second opinion – maybe Team Stream has an insight?(cc @addaleax)