mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 14:51:50 +00:00

errorOrDestroy emits 'error' synchronously due to compat reasons. However, it should be possible to use correct async behaviour for new code. PR-URL: https://github.com/nodejs/node/pull/29744 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
23 lines
572 B
JavaScript
23 lines
572 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const stream = require('stream');
|
|
|
|
const writable = new stream.Writable();
|
|
writable._write = (chunk, encoding, cb) => {
|
|
setTimeout(() => cb(), 10);
|
|
};
|
|
|
|
writable.end('testing ended state', common.mustCall());
|
|
writable.end(common.mustCall());
|
|
writable.on('finish', common.mustCall(() => {
|
|
let ticked = false;
|
|
writable.end(common.mustCall((err) => {
|
|
assert.strictEqual(ticked, true);
|
|
assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
|
|
}));
|
|
ticked = true;
|
|
}));
|