-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: error Duplex write/read if not writable/readable
If writable/readable has been explicitly disabled then using a Duplex as writable/readable should fail. Fixes: #34374 PR-URL: #34385 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
Showing
13 changed files
with
97 additions
and
83 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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