-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
test/parallel/test-stream-err-multiple-callback-construction.js
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,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(); |