node/test/parallel/test-stream-writable-final-destroy.js
Robert Nagy 7a7ba82234 stream: don't emit prefinish after error or close
PR-URL: https://github.com/nodejs/node/pull/39332
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-07-11 18:41:17 +02:00

22 lines
404 B
JavaScript

'use strict';
const common = require('../common');
const { Writable } = require('stream');
{
const w = new Writable({
write(chunk, encoding, callback) {
callback(null);
},
final(callback) {
queueMicrotask(callback);
}
});
w.end();
w.destroy();
w.on('prefinish', common.mustNotCall());
w.on('finish', common.mustNotCall());
w.on('close', common.mustCall());
}