| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 454d080 commit 63391e7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -876,7 +876,7 @@ function needFinish(state) { | |||
| 876 | 876 | ||
| 877 | 877 | function onFinish(stream, state, err) { | |
| 878 | 878 | if ((state[kState] & kPrefinished) !== 0) { | |
| 879 | - errorOrDestroy(stream, err ?? ERR_MULTIPLE_CALLBACK()); | ||
| 879 | + errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK()); | ||
| 880 | 880 | return; | |
| 881 | 881 | } | |
| 882 | 882 | state.pendingcb--; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const stream = require('stream'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + | ||
| 6 | + class TestWritable extends stream.Writable { | ||
| 7 | + _write(_chunk, _encoding, callback) { | ||
| 8 | + callback(); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + _final(callback) { | ||
| 12 | + process.nextTick(callback); | ||
| 13 | + process.nextTick(callback); | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + const writable = new TestWritable(); | ||
| 18 | + | ||
| 19 | + writable.on('finish', common.mustCall()); | ||
| 20 | + writable.on('error', common.mustCall((error) => { | ||
| 21 | + assert.strictEqual(error.message, 'Callback called multiple times'); | ||
| 22 | + })); | ||
| 23 | + | ||
| 24 | + writable.write('some data'); | ||
| 25 | + writable.end(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments