-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
stream: error Duplex write/read if not writable/readable #34385
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
Closed
Closed
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
157b6fe
stream: error Duplex write/read if not writable/readable
ronag 35c7e5e
fixup
ronag 43e1037
fixup
ronag 9e4fbbb
fixup
ronag e68fcc8
fixup
ronag 5468625
fixup
ronag 5e9a6f4
fixup
ronag 6fe226b
fixup
ronag 45108ac
fixup
ronag 8259042
fixup: re-enable dumb tty
ronag 71a9b6e
fixup
ronag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const { Duplex } = require('stream'); | ||
| const assert = require('assert'); | ||
|
|
||
| { | ||
| const duplex = new Duplex({ | ||
| readable: false | ||
| }); | ||
| assert.strictEqual(duplex.readable, false); | ||
| duplex.push('asd'); | ||
| duplex.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'ERR_STREAM_PUSH_AFTER_EOF'); | ||
| })); | ||
| duplex.on('data', common.mustNotCall()); | ||
| duplex.on('end', common.mustNotCall()); | ||
| } | ||
|
|
||
| { | ||
| const duplex = new Duplex({ | ||
| writable: false, | ||
| write: common.mustNotCall() | ||
| }); | ||
| assert.strictEqual(duplex.writable, false); | ||
| duplex.write('asd'); | ||
| duplex.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END'); | ||
| })); | ||
| duplex.on('finish', common.mustNotCall()); | ||
| } | ||
|
|
||
| { | ||
| const duplex = new Duplex({ | ||
| readable: false | ||
| }); | ||
| assert.strictEqual(duplex.readable, false); | ||
| duplex.on('data', common.mustNotCall()); | ||
| duplex.on('end', common.mustNotCall()); | ||
| async function run() { | ||
| for await (const chunk of duplex) { | ||
| assert(false, chunk); | ||
| } | ||
| } | ||
| run().then(common.mustCall()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,42 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
| const process = require('process'); | ||
|
|
||
| process.env.TERM = 'dumb'; | ||
| // TODO (fix): So this work on darwin/linux? | ||
| if (process.env === 'windows') { | ||
| process.env.TERM = 'dumb'; | ||
|
|
||
| const repl = require('repl'); | ||
| const ArrayStream = require('../common/arraystream'); | ||
| const repl = require('repl'); | ||
| const ArrayStream = require('../common/arraystream'); | ||
|
|
||
| repl.start('> '); | ||
| process.stdin.push('conso'); // No completion preview. | ||
| process.stdin.push('le.log("foo")\n'); | ||
| process.stdin.push('1 + 2'); // No input preview. | ||
| process.stdin.push('\n'); | ||
| process.stdin.push('"str"\n'); | ||
| process.stdin.push('console.dir({ a: 1 })\n'); | ||
| process.stdin.push('{ a: 1 }\n'); | ||
| process.stdin.push('\n'); | ||
| process.stdin.push('.exit\n'); | ||
| repl.start('> '); | ||
|
|
||
| // Verify <ctrl> + D support. | ||
| { | ||
| const stream = new ArrayStream(); | ||
| const replServer = new repl.REPLServer({ | ||
| prompt: '> ', | ||
| terminal: true, | ||
| input: stream, | ||
| output: process.stdout, | ||
| useColors: false | ||
| }); | ||
| // Verify <ctrl> + D support. | ||
| { | ||
| const stream = new ArrayStream(); | ||
| const replServer = new repl.REPLServer({ | ||
| prompt: '> ', | ||
| terminal: true, | ||
| input: stream, | ||
| output: process.stdout, | ||
| useColors: false | ||
| }); | ||
|
|
||
| replServer.on('close', common.mustCall()); | ||
| // Verify that <ctrl> + R or <ctrl> + C does not trigger the reverse search. | ||
| replServer.write(null, { ctrl: true, name: 'r' }); | ||
| replServer.write(null, { ctrl: true, name: 's' }); | ||
| replServer.write(null, { ctrl: true, name: 'd' }); | ||
| } | ||
|
|
||
| process.stdin.push('conso'); // No completion preview. | ||
| process.stdin.push('le.log("foo")\n'); | ||
| process.stdin.push('1 + 2'); // No input preview. | ||
| process.stdin.push('\n'); | ||
| process.stdin.push('"str"\n'); | ||
| process.stdin.push('console.dir({ a: 1 })\n'); | ||
| process.stdin.push('{ a: 1 }\n'); | ||
| process.stdin.push('\n'); | ||
| process.stdin.push('.exit\n'); | ||
|
|
||
| replServer.on('close', common.mustCall()); | ||
| // Verify that <ctrl> + R or <ctrl> + C does not trigger the reverse search. | ||
| replServer.write(null, { ctrl: true, name: 'r' }); | ||
| replServer.write(null, { ctrl: true, name: 's' }); | ||
| replServer.write(null, { ctrl: true, name: 'd' }); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.