async_hooks: remove deprecated API

PR-URL: https://github.com/nodejs/node/pull/17147
Refs: https://github.com/nodejs/node/pull/16972
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Andreas Madsen 2017-11-22 11:25:03 +01:00
parent f3b12aa4c2
commit 1cc6b993b9
No known key found for this signature in database
GPG Key ID: 2FEE61B3C9E40F20
5 changed files with 6 additions and 94 deletions

View File

@ -783,7 +783,7 @@ code modification is necessary if that is done.
<a id="DEP0085"></a>
### DEP0085: AsyncHooks Sensitive API
Type: Runtime
Type: End-of-Life
The AsyncHooks Sensitive API was never documented and had various of minor
issues, see https://github.com/nodejs/node/issues/15572. Use the `AsyncResource`
@ -793,7 +793,7 @@ API instead.
<a id="DEP0086"></a>
### DEP0086: Remove runInAsyncIdScope
Type: Runtime
Type: End-of-Life
`runInAsyncIdScope` doesn't emit the `before` or `after` event and can thus
cause a lot of issues. See https://github.com/nodejs/node/issues/14328 for more

View File

@ -1,14 +1,10 @@
'use strict';
const errors = require('internal/errors');
const internalUtil = require('internal/util');
const async_wrap = process.binding('async_wrap');
const internal_async_hooks = require('internal/async_hooks');
// Get functions
// Only used to support a deprecated API. pushAsyncIds, popAsyncIds should
// never be directly in this manner.
const { pushAsyncIds, popAsyncIds } = async_wrap;
// For userland AsyncResources, make sure to emit a destroy event when the
// resource gets gced.
const { registerDestroyHook } = async_wrap;
@ -17,10 +13,9 @@ const {
getHookArrays,
enableHooks,
disableHooks,
// Sensitive Embedder API
// Internal Embedder API
newUid,
initTriggerId,
setInitTriggerId,
emitInit,
emitBefore,
emitAfter,
@ -204,18 +199,6 @@ class AsyncResource {
}
function runInAsyncIdScope(asyncId, cb) {
// Store the async id now to make sure the stack is still good when the ids
// are popped off the stack.
const prevId = executionAsyncId();
pushAsyncIds(asyncId, prevId);
try {
cb();
} finally {
popAsyncIds(asyncId);
}
}
// Placing all exports down here because the exported classes won't export
// otherwise.
module.exports = {
@ -226,61 +209,3 @@ module.exports = {
// Embedder API
AsyncResource,
};
// Deprecated API //
Object.defineProperty(module.exports, 'runInAsyncIdScope', {
get: internalUtil.deprecate(function() {
return runInAsyncIdScope;
}, 'async_hooks.runInAsyncIdScope is deprecated. ' +
'Create an AsyncResource instead.', 'DEP0086')
});
Object.defineProperty(module.exports, 'newUid', {
get: internalUtil.deprecate(function() {
return newUid;
}, 'async_hooks.newUid is deprecated. ' +
'Use AsyncResource instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'initTriggerId', {
get: internalUtil.deprecate(function() {
return initTriggerId;
}, 'async_hooks.initTriggerId is deprecated. ' +
'Use the AsyncResource default instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'setInitTriggerId', {
get: internalUtil.deprecate(function() {
return setInitTriggerId;
}, 'async_hooks.setInitTriggerId is deprecated. ' +
'Use the triggerAsyncId parameter in AsyncResource instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'emitInit', {
get: internalUtil.deprecate(function() {
return emitInit;
}, 'async_hooks.emitInit is deprecated. ' +
'Use AsyncResource constructor instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'emitBefore', {
get: internalUtil.deprecate(function() {
return emitBefore;
}, 'async_hooks.emitBefore is deprecated. ' +
'Use AsyncResource.emitBefore instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'emitAfter', {
get: internalUtil.deprecate(function() {
return emitAfter;
}, 'async_hooks.emitAfter is deprecated. ' +
'Use AsyncResource.emitAfter instead.', 'DEP0085')
});
Object.defineProperty(module.exports, 'emitDestroy', {
get: internalUtil.deprecate(function() {
return emitDestroy;
}, 'async_hooks.emitDestroy is deprecated. ' +
'Use AsyncResource.emitDestroy instead.', 'DEP0085')
});

View File

@ -236,7 +236,7 @@ function disableHooks() {
async_hook_fields[kCheck] -= 1;
}
// Sensitive Embedder API //
// Internal Embedder API //
// Increment the internal id counter and return the value. Important that the
// counter increment first. Since it's done the same way in
@ -338,7 +338,7 @@ module.exports = {
},
enableHooks,
disableHooks,
// Sensitive Embedder API
// Internal Embedder API
newUid,
initTriggerId,
setInitTriggerId,

View File

@ -2,7 +2,7 @@
// Flags: --no-force-async-hooks-checks --expose-internals
const common = require('../common');
const async_hooks = require('async_hooks');
const async_hooks = require('internal/async_hooks');
const internal = require('internal/process/next_tick');
// Using undefined as the triggerAsyncId.

View File

@ -1,13 +0,0 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const asyncId = new async_hooks.AsyncResource('test').asyncId();
assert.notStrictEqual(async_hooks.executionAsyncId(), asyncId);
async_hooks.runInAsyncIdScope(asyncId, common.mustCall(() => {
assert.strictEqual(async_hooks.executionAsyncId(), asyncId);
}));