mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
stream: add new
when constructing ERR_MULTIPLE_CALLBACK
commit c71e548b65
changed NodeError
from a function to a class, and missed a spot where
`ERR_MULTIPLE_CALLBACK` was being instantiated. This commit fixes
that by adding the new keyword to that instance.
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/52110
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
454d0806a1
commit
63391e749d
@ -876,7 +876,7 @@ function needFinish(state) {
|
||||
|
||||
function onFinish(stream, state, err) {
|
||||
if ((state[kState] & kPrefinished) !== 0) {
|
||||
errorOrDestroy(stream, err ?? ERR_MULTIPLE_CALLBACK());
|
||||
errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK());
|
||||
return;
|
||||
}
|
||||
state.pendingcb--;
|
||||
|
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const stream = require('stream');
|
||||
const assert = require('assert');
|
||||
|
||||
class TestWritable extends stream.Writable {
|
||||
_write(_chunk, _encoding, callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
_final(callback) {
|
||||
process.nextTick(callback);
|
||||
process.nextTick(callback);
|
||||
}
|
||||
}
|
||||
|
||||
const writable = new TestWritable();
|
||||
|
||||
writable.on('finish', common.mustCall());
|
||||
writable.on('error', common.mustCall((error) => {
|
||||
assert.strictEqual(error.message, 'Callback called multiple times');
|
||||
}));
|
||||
|
||||
writable.write('some data');
|
||||
writable.end();
|
Loading…
Reference in New Issue
Block a user