| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent db94ab7 commit ee71952
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ bool JSStream::IsClosing() { | |||
| 46 | 46 | TryCatchScope try_catch(env()); | |
| 47 | 47 | Local<Value> value; | |
| 48 | 48 | if (!MakeCallback(env()->isclosing_string(), 0, nullptr).ToLocal(&value)) { | |
| 49 | - if (!try_catch.HasTerminated()) | ||
| 49 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) | ||
| 50 | 50 | FatalException(env()->isolate(), try_catch); | |
| 51 | 51 | return true; | |
| 52 | 52 | } | |
@@ -62,7 +62,7 @@ int JSStream::ReadStart() { | |||
| 62 | 62 | int value_int = UV_EPROTO; | |
| 63 | 63 | if (!MakeCallback(env()->onreadstart_string(), 0, nullptr).ToLocal(&value) || | |
| 64 | 64 | !value->Int32Value(env()->context()).To(&value_int)) { | |
| 65 | - if (!try_catch.HasTerminated()) | ||
| 65 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) | ||
| 66 | 66 | FatalException(env()->isolate(), try_catch); | |
| 67 | 67 | } | |
| 68 | 68 | return value_int; | |
@@ -77,7 +77,7 @@ int JSStream::ReadStop() { | |||
| 77 | 77 | int value_int = UV_EPROTO; | |
| 78 | 78 | if (!MakeCallback(env()->onreadstop_string(), 0, nullptr).ToLocal(&value) || | |
| 79 | 79 | !value->Int32Value(env()->context()).To(&value_int)) { | |
| 80 | - if (!try_catch.HasTerminated()) | ||
| 80 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) | ||
| 81 | 81 | FatalException(env()->isolate(), try_catch); | |
| 82 | 82 | } | |
| 83 | 83 | return value_int; | |
@@ -99,7 +99,7 @@ int JSStream::DoShutdown(ShutdownWrap* req_wrap) { | |||
| 99 | 99 | arraysize(argv), | |
| 100 | 100 | argv).ToLocal(&value) || | |
| 101 | 101 | !value->Int32Value(env()->context()).To(&value_int)) { | |
| 102 | - if (!try_catch.HasTerminated()) | ||
| 102 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) | ||
| 103 | 103 | FatalException(env()->isolate(), try_catch); | |
| 104 | 104 | } | |
| 105 | 105 | return value_int; | |
@@ -134,7 +134,7 @@ int JSStream::DoWrite(WriteWrap* w, | |||
| 134 | 134 | arraysize(argv), | |
| 135 | 135 | argv).ToLocal(&value) || | |
| 136 | 136 | !value->Int32Value(env()->context()).To(&value_int)) { | |
| 137 | - if (!try_catch.HasTerminated()) | ||
| 137 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) | ||
| 138 | 138 | FatalException(env()->isolate(), try_catch); | |
| 139 | 139 | } | |
| 140 | 140 | return value_int; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,39 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + if (!common.hasCrypto) | ||
| 4 | + common.skip('missing crypto'); | ||
| 5 | + | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + const http2 = require('http2'); | ||
| 8 | + const { Duplex } = require('stream'); | ||
| 9 | + const { Worker, workerData } = require('worker_threads'); | ||
| 10 | + | ||
| 11 | + // Tests the interaction between terminating a Worker thread and running | ||
| 12 | + // the native SetImmediate queue, which may attempt to perform multiple | ||
| 13 | + // calls into JS even though one already terminates the Worker. | ||
| 14 | + | ||
| 15 | + if (!workerData) { | ||
| 16 | + const counter = new Int32Array(new SharedArrayBuffer(4)); | ||
| 17 | + const worker = new Worker(__filename, { workerData: { counter } }); | ||
| 18 | + worker.on('exit', common.mustCall(() => { | ||
| 19 | + assert.strictEqual(counter[0], 1); | ||
| 20 | + })); | ||
| 21 | + } else { | ||
| 22 | + const { counter } = workerData; | ||
| 23 | + | ||
| 24 | + // Start two HTTP/2 connections. This will trigger write()s call from inside | ||
| 25 | + // the SetImmediate queue. | ||
| 26 | + for (let i = 0; i < 2; i++) { | ||
| 27 | + http2.connect('http://localhost', { | ||
| 28 | + createConnection() { | ||
| 29 | + return new Duplex({ | ||
| 30 | + write(chunk, enc, cb) { | ||
| 31 | + Atomics.add(counter, 0, 1); | ||
| 32 | + process.exit(); | ||
| 33 | + }, | ||
| 34 | + read() { } | ||
| 35 | + }); | ||
| 36 | + } | ||
| 37 | + }); | ||
| 38 | + } | ||
| 39 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments