diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-01-07 22:07:13 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-01-14 14:54:53 +0100 |
commit | 36daf1d6344137c7ab0e6b39998d1030721de45c (patch) | |
tree | 2ad7d30bae85b54e281d14e93da890ad6e9f1c43 /test/parallel/test-wrap-js-stream-exceptions.js | |
parent | 9301b8a9c69d112b98c7d60e074c845d80342b4e (diff) | |
download | android-node-v8-36daf1d6344137c7ab0e6b39998d1030721de45c.tar.gz android-node-v8-36daf1d6344137c7ab0e6b39998d1030721de45c.tar.bz2 android-node-v8-36daf1d6344137c7ab0e6b39998d1030721de45c.zip |
src: harden JSStream callbacks
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>
Diffstat (limited to 'test/parallel/test-wrap-js-stream-exceptions.js')
-rw-r--r-- | test/parallel/test-wrap-js-stream-exceptions.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-wrap-js-stream-exceptions.js b/test/parallel/test-wrap-js-stream-exceptions.js new file mode 100644 index 0000000000..57ecd70189 --- /dev/null +++ b/test/parallel/test-wrap-js-stream-exceptions.js @@ -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/); |