mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 20:06:58 +00:00

Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: https://github.com/nodejs/node/pull/17938#issuecomment-354683850 PR-URL: https://github.com/nodejs/node/pull/18028 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
20 lines
556 B
JavaScript
20 lines
556 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const JSStreamWrap = require('internal/wrap_js_stream');
|
|
const { Duplex } = require('stream');
|
|
|
|
process.once('uncaughtException', common.mustCall((err) => {
|
|
assert.strictEqual(err.message, 'exception!');
|
|
}));
|
|
|
|
const socket = new JSStreamWrap(new Duplex({
|
|
read: common.mustCall(),
|
|
write: common.mustCall((buffer, data, cb) => {
|
|
throw new Error('exception!');
|
|
})
|
|
}));
|
|
|
|
assert.throws(() => socket.end('foo'), /Error: write EPROTO/);
|