| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5b92eb4 commit 72f52a3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,23 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { Worker } = require('worker_threads'); | ||
| 5 | + | ||
| 6 | + // Check that `process.exit()` can be called inside a Worker from an uncaught | ||
| 7 | + // exception handler. | ||
| 8 | + | ||
| 9 | + // Do not use isMainThread so that this test itself can be run inside a Worker. | ||
| 10 | + if (!process.env.HAS_STARTED_WORKER) { | ||
| 11 | + process.env.HAS_STARTED_WORKER = 1; | ||
| 12 | + const w = new Worker(__filename); | ||
| 13 | + w.on('exit', common.mustCall((code) => { | ||
| 14 | + assert.strictEqual(code, 42); | ||
| 15 | + })); | ||
| 16 | + return; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + process.on('uncaughtException', () => { | ||
| 20 | + process.exit(42); | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + throw new Error(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments