0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-stream-writable-end-cb-uncaught.js
Robert Nagy efd40eadab stream: forward errored to callback
Refs: https://github.com/nodejs/node/issues/39356

PR-URL: https://github.com/nodejs/node/pull/39364
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-07-14 13:05:10 +02:00

25 lines
507 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();
const _err = new Error('kaboom');
writable._write = (chunk, encoding, cb) => {
cb();
};
writable._final = (cb) => {
cb(_err);
};
writable.write('asd');
writable.end(common.mustCall((err) => {
assert.strictEqual(err, _err);
}));