GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/test/parallel/test-async-hooks-promise-triggerid.js at main · styfle/node Expand file tree/ Copy pathtest-async-hooks-promise-triggerid.jsMore file actions 33 lines (29 loc) · 1.02 KB / Copy pathtest-async-hooks-promise-triggerid.jsFile metadata and controls33 lines (29 loc) · 1.02 KB 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 'use strict'; const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); if (!common.isMainThread) common.skip('Worker bootstrapping works differently -> different async IDs'); const promiseAsyncIds = []; async_hooks.createHook({ init: common.mustCallAtLeast((id, type, triggerId) => { if (type === 'PROMISE') { // Check that the last known Promise is triggering the creation of // this one. assert.strictEqual(triggerId, promiseAsyncIds[promiseAsyncIds.length - 1] || 1); promiseAsyncIds.push(id); } }, 3), before: common.mustCall((id) => { assert.strictEqual(id, promiseAsyncIds[1]); }), after: common.mustCall((id) => { assert.strictEqual(id, promiseAsyncIds[1]); }) }).enable(); Promise.resolve(42).then(common.mustCall(() => { assert.strictEqual(async_hooks.executionAsyncId(), promiseAsyncIds[1]); assert.strictEqual(async_hooks.triggerAsyncId(), promiseAsyncIds[0]); Promise.resolve(10); })); |
| 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. |