node/test/parallel/test-stream-writable-end-cb-uncaught.js
Robert Nagy c7e55c6b72 stream: fix writable.end callback behavior
Changes so that the end() callback behaves the same way in relation
to _final as write() does to _write/_writev.

PR-URL: https://github.com/nodejs/node/pull/34101
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-07-01 18:18:04 +02:00

24 lines
511 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const stream = require('stream');
process.on('uncaughtException', common.mustCall((err) => {
assert.strictEqual(err.message, 'kaboom');
}));
const writable = new stream.Writable();
writable._write = (chunk, encoding, cb) => {
cb();
};
writable._final = (cb) => {
cb(new Error('kaboom'));
};
writable.write('asd');
writable.end(common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED');
}));