Skip to content

Commit e30cf1e

Browse files
committed
stream: add new when constructing ERR_MULTIPLE_CALLBACK
commit c71e548 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.
1 parent ba06c5c commit e30cf1e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/internal/streams/writable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ function needFinish(state) {
876876

877877
function onFinish(stream, state, err) {
878878
if ((state[kState] & kPrefinished) !== 0) {
879-
errorOrDestroy(stream, err ?? ERR_MULTIPLE_CALLBACK());
879+
errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK());
880880
return;
881881
}
882882
state.pendingcb--;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const stream = require('stream');
2+
const assert = require('assert');
3+
4+
class TestWritable extends stream.Writable {
5+
_write(chunk, encoding, callback) {
6+
callback();
7+
}
8+
9+
_final(callback) {
10+
process.nextTick(callback);
11+
process.nextTick(callback);
12+
}
13+
}
14+
15+
const writable = new TestWritable();
16+
17+
writable.on('finish', () => {});
18+
writable.on('error', (error) => {
19+
assert.strictEqual(error.message, 'Callback called multiple times')
20+
});
21+
22+
writable.write('some data');
23+
writable.end();

0 commit comments

Comments
 (0)