-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: add null check in Readable.from
Throws `ERR_STREAM_NULL_VALUES` error if a null value is passed to `Readable.from`. Also added docs for the same. Co-Authored-By: 扩散性百万甜面包 <[email protected]> Fixes: #32845 PR-URL: #32873 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
const { mustNotCall, expectsError } = require('../common'); | ||
const { Readable } = require('stream'); | ||
|
||
async function* generate() { | ||
yield null; | ||
} | ||
|
||
const stream = Readable.from(generate()); | ||
|
||
stream.on('error', expectsError({ | ||
code: 'ERR_STREAM_NULL_VALUES', | ||
name: 'TypeError', | ||
message: 'May not write null values to stream' | ||
})); | ||
|
||
stream.on('data', mustNotCall((chunk) => {})); | ||
|
||
stream.on('end', mustNotCall()); |