mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
cf46746b8a
PR-URL: https://github.com/nodejs/node/pull/45549 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
28 lines
665 B
JavaScript
28 lines
665 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const initHooks = require('./init-hooks');
|
|
const async_hooks = require('async_hooks');
|
|
|
|
if (!common.isMainThread)
|
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
|
|
|
const promiseAsyncIds = [];
|
|
const hooks = initHooks({
|
|
oninit(asyncId, type) {
|
|
if (type === 'PROMISE') {
|
|
promiseAsyncIds.push(asyncId);
|
|
}
|
|
},
|
|
});
|
|
|
|
hooks.enable();
|
|
Promise.reject();
|
|
|
|
process.on('unhandledRejection', common.mustCall(() => {
|
|
assert.strictEqual(promiseAsyncIds.length, 1);
|
|
assert.strictEqual(async_hooks.executionAsyncId(), promiseAsyncIds[0]);
|
|
}));
|