MCPcopy Create free account
hub / github.com/nodejs/node / testAwait

Function testAwait

test/async-hooks/test-destroy-not-blocked.js:72–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72async function testAwait() {
73 assert.strictEqual(activeId, -1);
74 const res = new AsyncResource(resType);
75 assert.strictEqual(activeId, res.asyncId());
76 res.emitDestroy();
77
78 for (let i = 0; i < 5000; i++) {
79 await Promise.resolve();
80 }
81 global.gc();
82 await Promise.resolve();
83 // Limit to trigger a microtask not yet reached
84 assert.strictEqual(activeId, res.asyncId());
85 for (let i = 0; i < 5000; i++) {
86 await Promise.resolve();
87 }
88 global.gc();
89 await Promise.resolve();
90 assert.strictEqual(activeId, -1);
91}
92
93testNextTick();
94tick(2, testQueueMicrotask);

Callers 1

Calls 3

asyncIdMethod · 0.95
emitDestroyMethod · 0.95
resolveMethod · 0.45

Tested by

no test coverage detected