GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: regression tests for async_hooks + Promise + Worker interaction · nodejs/node@b93a723

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-async-hooks-worker-asyncfn-terminate-1.js
    • test-async-hooks-worker-asyncfn-terminate-2.js
    • test-async-hooks-worker-asyncfn-terminate-3.js
    • test-async-hooks-worker-asyncfn-terminate-4.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-async-hooks-worker-asyncfn-terminate-1.js‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { Worker } = require('worker_threads');
4+
5+
const w = new Worker(`
6+
const { createHook } = require('async_hooks');
7+
8+
setImmediate(async () => {
9+
createHook({ init() {} }).enable();
10+
await 0;
11+
process.exit();
12+
});
13+
`, { eval: true });
14+
15+
w.on('exit', common.mustCall());
Collapse file

‎test/parallel/test-async-hooks-worker-asyncfn-terminate-2.js‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { Worker } = require('worker_threads');
4+
5+
// Like test-async-hooks-worker-promise.js but with the `await` and `createHook`
6+
// lines switched, because that resulted in different assertion failures
7+
// (one a Node.js assertion and one a V8 DCHECK) and it seems prudent to
8+
// cover both of those failures.
9+
10+
const w = new Worker(`
11+
const { createHook } = require('async_hooks');
12+
13+
setImmediate(async () => {
14+
await 0;
15+
createHook({ init() {} }).enable();
16+
process.exit();
17+
});
18+
`, { eval: true });
19+
20+
w.postMessage({});
21+
w.on('exit', common.mustCall());
Collapse file

‎test/parallel/test-async-hooks-worker-asyncfn-terminate-3.js‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { Worker } = require('worker_threads');
4+
5+
// Like test-async-hooks-worker-promise.js but with an additional statement
6+
// after the `process.exit()` call, that shouldn’t really make a difference
7+
// but apparently does.
8+
9+
const w = new Worker(`
10+
const { createHook } = require('async_hooks');
11+
12+
setImmediate(async () => {
13+
createHook({ init() {} }).enable();
14+
await 0;
15+
process.exit();
16+
process._rawDebug('THIS SHOULD NEVER BE REACHED');
17+
});
18+
`, { eval: true });
19+
20+
w.on('exit', common.mustCall());
Collapse file

‎test/parallel/test-async-hooks-worker-asyncfn-terminate-4.js‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const { Worker } = require('worker_threads');
5+
6+
// Like test-async-hooks-worker-promise.js but doing a trivial counter increase
7+
// after process.exit(). This should not make a difference, but apparently it
8+
// does. This is *also* different from test-async-hooks-worker-promise-3.js,
9+
// in that the statement is an ArrayBuffer access rather than a full method,
10+
// which *also* makes a difference even though it shouldn’t.
11+
12+
const workerData = new Int32Array(new SharedArrayBuffer(4));
13+
const w = new Worker(`
14+
const { createHook } = require('async_hooks');
15+
16+
setImmediate(async () => {
17+
createHook({ init() {} }).enable();
18+
await 0;
19+
process.exit();
20+
workerData[0]++;
21+
});
22+
`, { eval: true, workerData });
23+
24+
w.on('exit', common.mustCall(() => assert.strictEqual(workerData[0], 0)));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.