-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since these are executing JS code, and in particular parts of that code may be provided by userland, handle such exceptions in C++. Refs: #17938 (comment) PR-URL: #18028 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
- Loading branch information
Showing
2 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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/); |