mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

Throws `ERR_STREAM_NULL_VALUES` error if a null value is passed to `Readable.from`. Also added docs for the same. Co-Authored-By: 扩散性百万甜面包 <himself65@outlook.com> Fixes: https://github.com/nodejs/node/issues/32845 PR-URL: https://github.com/nodejs/node/pull/32873 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
20 lines
429 B
JavaScript
20 lines
429 B
JavaScript
'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());
|