Skip to content

Commit 1cc6b99

Browse files
committed
async_hooks: remove deprecated API
PR-URL: #17147 Refs: #16972 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent f3b12aa commit 1cc6b99

File tree

5 files changed

+6
-94
lines changed

5 files changed

+6
-94
lines changed

doc/api/deprecations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ code modification is necessary if that is done.
783783
<a id="DEP0085"></a>
784784
### DEP0085: AsyncHooks Sensitive API
785785
786-
Type: Runtime
786+
Type: End-of-Life
787787
788788
The AsyncHooks Sensitive API was never documented and had various of minor
789789
issues, see https://github.com/nodejs/node/issues/15572. Use the `AsyncResource`
@@ -793,7 +793,7 @@ API instead.
793793
<a id="DEP0086"></a>
794794
### DEP0086: Remove runInAsyncIdScope
795795
796-
Type: Runtime
796+
Type: End-of-Life
797797
798798
`runInAsyncIdScope` doesn't emit the `before` or `after` event and can thus
799799
cause a lot of issues. See https://github.com/nodejs/node/issues/14328 for more

lib/async_hooks.js

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
'use strict';
22

33
const errors = require('internal/errors');
4-
const internalUtil = require('internal/util');
54
const async_wrap = process.binding('async_wrap');
65
const internal_async_hooks = require('internal/async_hooks');
76

87
// Get functions
9-
// Only used to support a deprecated API. pushAsyncIds, popAsyncIds should
10-
// never be directly in this manner.
11-
const { pushAsyncIds, popAsyncIds } = async_wrap;
128
// For userland AsyncResources, make sure to emit a destroy event when the
139
// resource gets gced.
1410
const { registerDestroyHook } = async_wrap;
@@ -17,10 +13,9 @@ const {
1713
getHookArrays,
1814
enableHooks,
1915
disableHooks,
20-
// Sensitive Embedder API
16+
// Internal Embedder API
2117
newUid,
2218
initTriggerId,
23-
setInitTriggerId,
2419
emitInit,
2520
emitBefore,
2621
emitAfter,
@@ -204,18 +199,6 @@ class AsyncResource {
204199
}
205200

206201

207-
function runInAsyncIdScope(asyncId, cb) {
208-
// Store the async id now to make sure the stack is still good when the ids
209-
// are popped off the stack.
210-
const prevId = executionAsyncId();
211-
pushAsyncIds(asyncId, prevId);
212-
try {
213-
cb();
214-
} finally {
215-
popAsyncIds(asyncId);
216-
}
217-
}
218-
219202
// Placing all exports down here because the exported classes won't export
220203
// otherwise.
221204
module.exports = {
@@ -226,61 +209,3 @@ module.exports = {
226209
// Embedder API
227210
AsyncResource,
228211
};
229-
230-
// Deprecated API //
231-
232-
Object.defineProperty(module.exports, 'runInAsyncIdScope', {
233-
get: internalUtil.deprecate(function() {
234-
return runInAsyncIdScope;
235-
}, 'async_hooks.runInAsyncIdScope is deprecated. ' +
236-
'Create an AsyncResource instead.', 'DEP0086')
237-
});
238-
239-
Object.defineProperty(module.exports, 'newUid', {
240-
get: internalUtil.deprecate(function() {
241-
return newUid;
242-
}, 'async_hooks.newUid is deprecated. ' +
243-
'Use AsyncResource instead.', 'DEP0085')
244-
});
245-
246-
Object.defineProperty(module.exports, 'initTriggerId', {
247-
get: internalUtil.deprecate(function() {
248-
return initTriggerId;
249-
}, 'async_hooks.initTriggerId is deprecated. ' +
250-
'Use the AsyncResource default instead.', 'DEP0085')
251-
});
252-
253-
Object.defineProperty(module.exports, 'setInitTriggerId', {
254-
get: internalUtil.deprecate(function() {
255-
return setInitTriggerId;
256-
}, 'async_hooks.setInitTriggerId is deprecated. ' +
257-
'Use the triggerAsyncId parameter in AsyncResource instead.', 'DEP0085')
258-
});
259-
260-
Object.defineProperty(module.exports, 'emitInit', {
261-
get: internalUtil.deprecate(function() {
262-
return emitInit;
263-
}, 'async_hooks.emitInit is deprecated. ' +
264-
'Use AsyncResource constructor instead.', 'DEP0085')
265-
});
266-
267-
Object.defineProperty(module.exports, 'emitBefore', {
268-
get: internalUtil.deprecate(function() {
269-
return emitBefore;
270-
}, 'async_hooks.emitBefore is deprecated. ' +
271-
'Use AsyncResource.emitBefore instead.', 'DEP0085')
272-
});
273-
274-
Object.defineProperty(module.exports, 'emitAfter', {
275-
get: internalUtil.deprecate(function() {
276-
return emitAfter;
277-
}, 'async_hooks.emitAfter is deprecated. ' +
278-
'Use AsyncResource.emitAfter instead.', 'DEP0085')
279-
});
280-
281-
Object.defineProperty(module.exports, 'emitDestroy', {
282-
get: internalUtil.deprecate(function() {
283-
return emitDestroy;
284-
}, 'async_hooks.emitDestroy is deprecated. ' +
285-
'Use AsyncResource.emitDestroy instead.', 'DEP0085')
286-
});

lib/internal/async_hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function disableHooks() {
236236
async_hook_fields[kCheck] -= 1;
237237
}
238238

239-
// Sensitive Embedder API //
239+
// Internal Embedder API //
240240

241241
// Increment the internal id counter and return the value. Important that the
242242
// counter increment first. Since it's done the same way in
@@ -338,7 +338,7 @@ module.exports = {
338338
},
339339
enableHooks,
340340
disableHooks,
341-
// Sensitive Embedder API
341+
// Internal Embedder API
342342
newUid,
343343
initTriggerId,
344344
setInitTriggerId,

test/async-hooks/test-no-assert-when-disabled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Flags: --no-force-async-hooks-checks --expose-internals
33
const common = require('../common');
44

5-
const async_hooks = require('async_hooks');
5+
const async_hooks = require('internal/async_hooks');
66
const internal = require('internal/process/next_tick');
77

88
// Using undefined as the triggerAsyncId.

test/parallel/test-async-hooks-run-in-async-id-scope.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)