Port the domain module from createHook (async_hooks) to AsyncLocalStorage using the AsyncContextFrame-based implementation. Key changes: - Use AsyncLocalStorage for domain context propagation instead of async_hooks.createHook() - Lazy initialization that triggers AsyncContextFrame prototype swap on first domain use - Use enterWith instead of ALS.run() so domain context is NOT automatically restored on exception - this matches the original domain.run() behavior where exit() only runs on success - Add ERR_ASYNC_RESOURCE_DOMAIN_REMOVED error for AsyncResource.domain - Update DEP0097 to End-of-Life status - Remove tests that relied on the removed MakeCallback domain property The domain module now uses the AsyncContextFrame version of AsyncLocalStorage directly for proper context propagation across async boundaries. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/61095 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
25 lines
741 B
JavaScript
25 lines
741 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const domain = require('domain');
|
|
const assert = require('assert');
|
|
|
|
const d = domain.create();
|
|
|
|
process.once('uncaughtException', common.mustCall(function onUncaught() {
|
|
assert.strictEqual(
|
|
process.domain, undefined,
|
|
'Domains stack should be empty in uncaughtException handler ' +
|
|
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
|
|
}));
|
|
|
|
process.on('beforeExit', common.mustCall(function onBeforeExit() {
|
|
assert.strictEqual(
|
|
process.domain, undefined,
|
|
'Domains stack should be empty in beforeExit handler ' +
|
|
`but the value of process.domain is ${JSON.stringify(process.domain)}`);
|
|
}));
|
|
|
|
d.run(function() {
|
|
throw new Error('boom');
|
|
});
|