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-promise-enable-disable.js at main · synapse/node

Expand file tree

/

test-async-hooks-promise-enable-disable.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
44 lines (39 loc) · 1.13 KB
/

test-async-hooks-promise-enable-disable.js

Copy path

File metadata and controls

44 lines (39 loc) · 1.13 KB
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
38
39
40
41
42
43
44
'use strict';
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const EXPECTED_INITS = 2;
let p_er = null;
let p_inits = 0;
// Not useful to place common.mustCall() around 'exit' event b/c it won't be
// able to check it anyway.
process.on('exit', (code) => {
if (code !== 0)
return;
if (p_er !== null)
throw p_er;
// Expecting exactly 2 PROMISE types to reach init.
assert.strictEqual(p_inits, EXPECTED_INITS);
});
const mustCallInit = common.mustCall(function init(id, type, tid, resource) {
if (type !== 'PROMISE')
return;
p_inits++;
}, EXPECTED_INITS);
const hook = async_hooks.createHook({
init: mustCallInit
// Enable then disable to test whether disable() actually works.
}).enable().disable().disable();
new Promise(common.mustCall((res) => {
res(42);
})).then(common.mustCall((val) => {
hook.enable().enable();
const p = new Promise((res) => res(val));
hook.disable();
return p;
})).then(common.mustCall((val2) => {
hook.enable();
const p = new Promise((res) => res(val2));
hook.disable();
return p;
})).catch((er) => p_er = er);
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.