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 — node/test/parallel/test-async-hooks-close-during-destroy.js at main · styfle/node

Expand file tree

/

test-async-hooks-close-during-destroy.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
37 lines (31 loc) · 990 Bytes
/

test-async-hooks-close-during-destroy.js

Copy path

File metadata and controls

37 lines (31 loc) · 990 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
// Test that async ids that are added to the destroy queue while running a
// `destroy` callback are handled correctly.
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const initCalls = new Set();
let destroyResCallCount = 0;
let res2;
async_hooks.createHook({
init: common.mustCallAtLeast((id, provider) => {
if (provider === 'foobar')
initCalls.add(id);
}, 2),
destroy: common.mustCallAtLeast((id) => {
if (!initCalls.has(id)) return;
switch (destroyResCallCount++) {
case 0:
// Trigger the second `destroy` call.
res2.emitDestroy();
break;
case 2:
assert.fail('More than 2 destroy() invocations');
break;
}
}, 2)
}).enable();
const res1 = new async_hooks.AsyncResource('foobar');
res2 = new async_hooks.AsyncResource('foobar');
res1.emitDestroy();
process.on('exit', () => assert.strictEqual(destroyResCallCount, 2));
You are visitor 01402792 — 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.