diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md
index 555a8bee61515e..402bba9c635330 100644
--- a/doc/api/async_hooks.md
+++ b/doc/api/async_hooks.md
@@ -29,11 +29,11 @@ Following is a simple overview of the public API.
const async_hooks = require('async_hooks');
// Return the ID of the current execution context.
-const cid = async_hooks.currentId();
+const eid = async_hooks.executionAsyncId();
// Return the ID of the handle responsible for triggering the callback of the
// current execution scope to call.
-const tid = async_hooks.triggerId();
+const tid = async_hooks.triggerAsyncId();
// Create a new AsyncHook instance. All of these callbacks are optional.
const asyncHook = async_hooks.createHook({ init, before, after, destroy });
@@ -53,7 +53,7 @@ asyncHook.disable();
// init is called during object construction. The resource may not have
// completed construction when this callback runs, therefore all fields of the
// resource referenced by "asyncId" may not have been populated.
-function init(asyncId, type, triggerId, resource) { }
+function init(asyncId, type, triggerAsyncId, resource) { }
// before is called just before the resource's callback is called. It can be
// called 0-N times for handles (e.g. TCPWrap), and will be called exactly 1
@@ -163,11 +163,11 @@ Key events in the lifetime of asynchronous events have been categorized into
four areas: instantiation, before/after the callback is called, and when the
instance is destructed.
-##### `init(asyncId, type, triggerId, resource)`
+##### `init(asyncId, type, triggerAsyncId, resource)`
* `asyncId` {number} a unique ID for the async resource
* `type` {string} the type of the async resource
-* `triggerId` {number} the unique ID of the async resource in whose
+* `triggerAsyncId` {number} the unique ID of the async resource in whose
execution context this async resource was created
* `resource` {Object} reference to the resource representing the async operation,
needs to be released during _destroy_
@@ -214,20 +214,20 @@ when listening to the hooks.
###### `triggerId`
-`triggerId` is the `asyncId` of the resource that caused (or "triggered") the
+`triggerAsyncId` is the `asyncId` of the resource that caused (or "triggered") the
new resource to initialize and that caused `init` to call. This is different
-from `async_hooks.currentId()` that only shows *when* a resource was created,
-while `triggerId` shows *why* a resource was created.
+from `async_hooks.executionAsyncId()` that only shows *when* a resource was
+created, while `triggerAsyncId` shows *why* a resource was created.
-The following is a simple demonstration of `triggerId`:
+The following is a simple demonstration of `triggerAsyncId`:
```js
async_hooks.createHook({
- init(asyncId, type, triggerId) {
- const cId = async_hooks.currentId();
+ init(asyncId, type, triggerAsyncId) {
+ const eid = async_hooks.executionAsyncId();
fs.writeSync(
- 1, `${type}(${asyncId}): trigger: ${triggerId} scope: ${cId}\n`);
+ 1, `${type}(${asyncId}): trigger: ${triggerAsyncId} execution: ${eid}\n`);
}
}).enable();
@@ -237,18 +237,18 @@ require('net').createServer((conn) => {}).listen(8080);
Output when hitting the server with `nc localhost 8080`:
```
-TCPWRAP(2): trigger: 1 scope: 1
-TCPWRAP(4): trigger: 2 scope: 0
+TCPWRAP(2): trigger: 1 execution: 1
+TCPWRAP(4): trigger: 2 execution: 0
```
The first `TCPWRAP` is the server which receives the connections.
The second `TCPWRAP` is the new connection from the client. When a new
connection is made the `TCPWrap` instance is immediately constructed. This
-happens outside of any JavaScript stack (side note: a `currentId()` of `0`
+happens outside of any JavaScript stack (side note: a `executionAsyncId()` of `0`
means it's being executed from C++, with no JavaScript stack above it).
With only that information it would be impossible to link resources together in
-terms of what caused them to be created, so `triggerId` is given the task of
+terms of what caused them to be created, so `triggerAsyncId` is given the task of
propagating what resource is responsible for the new resource's existence.
###### `resource`
@@ -280,12 +280,13 @@ elaborate to make calling context easier to see.
```js
let indent = 0;
async_hooks.createHook({
- init(asyncId, type, triggerId) {
- const cId = async_hooks.currentId();
+ init(asyncId, type, triggerAsyncId) {
+ const eid = async_hooks.executionAsyncId();
const indentStr = ' '.repeat(indent);
fs.writeSync(
1,
- `${indentStr}${type}(${asyncId}): trigger: ${triggerId} scope: ${cId}\n`);
+ `${indentStr}${type}(${asyncId}):` +
+ ` trigger: ${triggerAsyncId} execution: ${eid}\n`);
},
before(asyncId) {
const indentStr = ' '.repeat(indent);
@@ -306,7 +307,7 @@ async_hooks.createHook({
require('net').createServer(() => {}).listen(8080, () => {
// Let's wait 10ms before logging the server started.
setTimeout(() => {
- console.log('>>>', async_hooks.currentId());
+ console.log('>>>', async_hooks.executionAsyncId());
}, 10);
});
```
@@ -314,20 +315,20 @@ require('net').createServer(() => {}).listen(8080, () => {
Output from only starting the server:
```
-TCPWRAP(2): trigger: 1 scope: 1
-TickObject(3): trigger: 2 scope: 1
+TCPWRAP(2): trigger: 1 execution: 1
+TickObject(3): trigger: 2 execution: 1
before: 3
- Timeout(4): trigger: 3 scope: 3
- TIMERWRAP(5): trigger: 3 scope: 3
+ Timeout(4): trigger: 3 execution: 3
+ TIMERWRAP(5): trigger: 3 execution: 3
after: 3
destroy: 3
before: 5
before: 4
- TTYWRAP(6): trigger: 4 scope: 4
- SIGNALWRAP(7): trigger: 4 scope: 4
- TTYWRAP(8): trigger: 4 scope: 4
+ TTYWRAP(6): trigger: 4 execution: 4
+ SIGNALWRAP(7): trigger: 4 execution: 4
+ TTYWRAP(8): trigger: 4 execution: 4
>>> 4
- TickObject(9): trigger: 4 scope: 4
+ TickObject(9): trigger: 4 execution: 4
after: 4
after: 5
before: 9
@@ -337,11 +338,11 @@ destroy: 9
destroy: 5
```
-*Note*: As illustrated in the example, `currentId()` and `scope` each specify
-the value of the current execution context; which is delineated by calls to
-`before` and `after`.
+*Note*: As illustrated in the example, `executionAsyncId()` and `execution`
+each specify the value of the current execution context; which is delineated by
+calls to `before` and `after`.
-Only using `scope` to graph resource allocation results in the following:
+Only using `execution` to graph resource allocation results in the following:
```
TTYWRAP(6) -> Timeout(4) -> TIMERWRAP(5) -> TickObject(3) -> root(1)
@@ -353,7 +354,7 @@ hostname is actually synchronous, but to maintain a completely asynchronous API
the user's callback is placed in a `process.nextTick()`.
The graph only shows *when* a resource was created, not *why*, so to track
-the *why* use `triggerId`.
+the *why* use `triggerAsyncId`.
##### `before(asyncId)`
@@ -396,7 +397,7 @@ the `resource` object passed to `init` it's possible that `destroy` is
never called, causing a memory leak in the application. Of course if
the resource doesn't depend on GC then this isn't an issue.
-#### `async_hooks.currentId()`
+#### `async_hooks.executionAsyncId()`
* Returns {number} the `asyncId` of the current execution context. Useful to track
when something calls.
@@ -404,14 +405,14 @@ the resource doesn't depend on GC then this isn't an issue.
For example:
```js
-console.log(async_hooks.currentId()); // 1 - bootstrap
+console.log(async_hooks.executionAsyncId()); // 1 - bootstrap
fs.open(path, 'r', (err, fd) => {
- console.log(async_hooks.currentId()); // 6 - open()
+ console.log(async_hooks.executionAsyncId()); // 6 - open()
});
```
-It is important to note that the ID returned fom `currentId()` is related to
-execution timing, not causality (which is covered by `triggerId()`). For
+It is important to note that the ID returned fom `executionAsyncId()` is related
+to execution timing, not causality (which is covered by `triggerAsyncId()`). For
example:
```js
@@ -419,16 +420,16 @@ const server = net.createServer(function onConnection(conn) {
// Returns the ID of the server, not of the new connection, because the
// onConnection callback runs in the execution scope of the server's
// MakeCallback().
- async_hooks.currentId();
+ async_hooks.executionAsyncId();
}).listen(port, function onListening() {
// Returns the ID of a TickObject (i.e. process.nextTick()) because all
// callbacks passed to .listen() are wrapped in a nextTick().
- async_hooks.currentId();
+ async_hooks.executionAsyncId();
});
```
-#### `async_hooks.triggerId()`
+#### `async_hooks.triggerAsyncId()`
* Returns {number} the ID of the resource responsible for calling the callback
that is currently being executed.
@@ -438,15 +439,15 @@ For example:
```js
const server = net.createServer((conn) => {
// The resource that caused (or triggered) this callback to be called
- // was that of the new connection. Thus the return value of triggerId()
+ // was that of the new connection. Thus the return value of triggerAsyncId()
// is the asyncId of "conn".
- async_hooks.triggerId();
+ async_hooks.triggerAsyncId();
}).listen(port, () => {
// Even though all callbacks passed to .listen() are wrapped in a nextTick()
// the callback itself exists because the call to the server's .listen()
// was made. So the return value would be the ID of the server.
- async_hooks.triggerId();
+ async_hooks.triggerAsyncId();
});
```
@@ -475,9 +476,9 @@ The following is an overview of the `AsyncResource` API.
const { AsyncResource } = require('async_hooks');
// AsyncResource() is meant to be extended. Instantiating a
-// new AsyncResource() also triggers init. If triggerId is omitted then
-// async_hook.currentId() is used.
-const asyncResource = new AsyncResource(type, triggerId);
+// new AsyncResource() also triggers init. If triggerAsyncId is omitted then
+// async_hook.executionAsyncId() is used.
+const asyncResource = new AsyncResource(type, triggerAsyncId);
// Call AsyncHooks before callbacks.
asyncResource.emitBefore();
@@ -492,14 +493,14 @@ asyncResource.emitDestroy();
asyncResource.asyncId();
// Return the trigger ID for the AsyncResource instance.
-asyncResource.triggerId();
+asyncResource.triggerAsyncId();
```
-#### `AsyncResource(type[, triggerId])`
+#### `AsyncResource(type[, triggerAsyncId])`
* arguments
* `type` {string} the type of ascyc event
- * `triggerId` {number} the ID of the execution context that created this async
+ * `triggerAsyncId` {number} the ID of the execution context that created this async
event
Example usage:
@@ -558,9 +559,9 @@ never be called.
* Returns {number} the unique `asyncId` assigned to the resource.
-#### `asyncResource.triggerId()`
+#### `asyncResource.triggerAsyncId()`
-* Returns {number} the same `triggerId` that is passed to the `AsyncResource`
+* Returns {number} the same `triggerAsyncId` that is passed to the `AsyncResource`
constructor.
[`Hook Callbacks`]: #hook-callbacks
diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index b66b9c5a5c5dad..caa8ef04efec6c 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -600,6 +600,36 @@ The DebugContext will be removed in V8 soon and will not be available in Node
*Note*: DebugContext was an experimental API.
+
+### DEP0070: async_hooks.currentId()
+
+Type: Runtime
+
+`async_hooks.currentId()` was renamed to `async_hooks.executionAsyncId()` for
+clarity.
+
+*Note*: change was made while `async_hooks` was an experimental API.
+
+
+### DEP0071: async_hooks.triggerId()
+
+Type: Runtime
+
+`async_hooks.triggerId()` was renamed to `async_hooks.triggerAsyncId()` for
+clarity.
+
+*Note*: change was made while `async_hooks` was an experimental API.
+
+
+### DEP0072: async_hooks.AsyncResource.triggerId()
+
+Type: Runtime
+
+`async_hooks.AsyncResource.triggerId()` was renamed to
+`async_hooks.AsyncResource.triggerAsyncId()` for clarity.
+
+*Note*: change was made while `async_hooks` was an experimental API.
+
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
diff --git a/lib/async_hooks.js b/lib/async_hooks.js
index 53ce0382348042..e1029c97a57eec 100644
--- a/lib/async_hooks.js
+++ b/lib/async_hooks.js
@@ -1,5 +1,6 @@
'use strict';
+const internalUtil = require('internal/util');
const async_wrap = process.binding('async_wrap');
/* Both these arrays are used to communicate between JS and C++ with as little
* overhead as possible.
@@ -191,12 +192,12 @@ function createHook(fns) {
}
-function currentId() {
+function executionAsyncId() {
return async_uid_fields[kCurrentAsyncId];
}
-function triggerId() {
+function triggerAsyncId() {
return async_uid_fields[kCurrentTriggerId];
}
@@ -204,28 +205,28 @@ function triggerId() {
// Embedder API //
class AsyncResource {
- constructor(type, triggerId) {
+ constructor(type, triggerAsyncId) {
this[async_id_symbol] = ++async_uid_fields[kAsyncUidCntr];
// Read and reset the current kInitTriggerId so that when the constructor
// finishes the kInitTriggerId field is always 0.
- if (triggerId === undefined) {
- triggerId = initTriggerId();
- // If a triggerId was passed, any kInitTriggerId still must be null'd.
+ if (triggerAsyncId === undefined) {
+ triggerAsyncId = initTriggerId();
+ // If a triggerAsyncId was passed, any kInitTriggerId still must be null'd.
} else {
async_uid_fields[kInitTriggerId] = 0;
}
- this[trigger_id_symbol] = triggerId;
+ this[trigger_id_symbol] = triggerAsyncId;
if (typeof type !== 'string' || type.length <= 0)
throw new TypeError('type must be a string with length > 0');
- if (!Number.isSafeInteger(triggerId) || triggerId < 0)
- throw new RangeError('triggerId must be an unsigned integer');
+ if (!Number.isSafeInteger(triggerAsyncId) || triggerAsyncId < 0)
+ throw new RangeError('triggerAsyncId must be an unsigned integer');
// Return immediately if there's nothing to do.
if (async_hook_fields[kInit] === 0)
return;
- init(this[async_id_symbol], type, triggerId, this);
+ init(this[async_id_symbol], type, triggerAsyncId, this);
}
emitBefore() {
@@ -247,16 +248,27 @@ class AsyncResource {
return this[async_id_symbol];
}
- triggerId() {
+ triggerAsyncId() {
return this[trigger_id_symbol];
}
}
+// triggerId was renamed to triggerAsyncId. This was in 8.2.0 during the
+// experimental stage so the alias can be removed at any time, we are just
+// being nice :)
+Object.defineProperty(AsyncResource.prototype, 'triggerId', {
+ get: internalUtil.deprecate(function() {
+ return AsyncResource.prototype.triggerAsyncId;
+ }, 'AsyncResource.triggerId is deprecated. ' +
+ 'Use AsyncResource.triggerAsyncId instead.', 'DEP0072')
+});
+
+
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 = currentId();
+ const prevId = executionAsyncId();
pushAsyncIds(asyncId, prevId);
try {
cb();
@@ -276,8 +288,8 @@ function newUid() {
}
-// Return the triggerId meant for the constructor calling it. It's up to the
-// user to safeguard this call and make sure it's zero'd out when the
+// Return the triggerAsyncId meant for the constructor calling it. It's up to
+// the user to safeguard this call and make sure it's zero'd out when the
// constructor is complete.
function initTriggerId() {
var tId = async_uid_fields[kInitTriggerId];
@@ -290,14 +302,14 @@ function initTriggerId() {
}
-function setInitTriggerId(triggerId) {
- // CHECK(Number.isSafeInteger(triggerId))
- // CHECK(triggerId > 0)
- async_uid_fields[kInitTriggerId] = triggerId;
+function setInitTriggerId(triggerAsyncId) {
+ // CHECK(Number.isSafeInteger(triggerAsyncId))
+ // CHECK(triggerAsyncId > 0)
+ async_uid_fields[kInitTriggerId] = triggerAsyncId;
}
-function emitInitS(asyncId, type, triggerId, resource) {
+function emitInitS(asyncId, type, triggerAsyncId, resource) {
// Short circuit all checks for the common case. Which is that no hooks have
// been set. Do this to remove performance impact for embedders (and core).
// Even though it bypasses all the argument checks. The performance savings
@@ -307,10 +319,10 @@ function emitInitS(asyncId, type, triggerId, resource) {
// This can run after the early return check b/c running this function
// manually means that the embedder must have used initTriggerId().
- if (!Number.isSafeInteger(triggerId)) {
- if (triggerId !== undefined)
- resource = triggerId;
- triggerId = initTriggerId();
+ if (!Number.isSafeInteger(triggerAsyncId)) {
+ if (triggerAsyncId !== undefined)
+ resource = triggerAsyncId;
+ triggerAsyncId = initTriggerId();
}
// I'd prefer allowing these checks to not exist, or only throw in a debug
@@ -319,10 +331,10 @@ function emitInitS(asyncId, type, triggerId, resource) {
throw new RangeError('asyncId must be an unsigned integer');
if (typeof type !== 'string' || type.length <= 0)
throw new TypeError('type must be a string with length > 0');
- if (!Number.isSafeInteger(triggerId) || triggerId < 0)
- throw new RangeError('triggerId must be an unsigned integer');
+ if (!Number.isSafeInteger(triggerAsyncId) || triggerAsyncId < 0)
+ throw new RangeError('triggerAsyncId must be an unsigned integer');
- init(asyncId, type, triggerId, resource);
+ init(asyncId, type, triggerAsyncId, resource);
// Isn't null if hooks were added/removed while the hooks were running.
if (tmp_active_hooks_array !== null) {
@@ -351,19 +363,19 @@ function emitBeforeN(asyncId) {
}
-// Usage: emitBeforeS(asyncId[, triggerId]). If triggerId is omitted then
-// asyncId will be used instead.
-function emitBeforeS(asyncId, triggerId = asyncId) {
+// Usage: emitBeforeS(asyncId[, triggerAsyncId]). If triggerAsyncId is omitted
+// then asyncId will be used instead.
+function emitBeforeS(asyncId, triggerAsyncId = asyncId) {
// CHECK(Number.isSafeInteger(asyncId) && asyncId > 0)
- // CHECK(Number.isSafeInteger(triggerId) && triggerId > 0)
+ // CHECK(Number.isSafeInteger(triggerAsyncId) && triggerAsyncId > 0)
// Validate the ids.
- if (asyncId < 0 || triggerId < 0) {
- fatalError('before(): asyncId or triggerId is less than zero ' +
- `(asyncId: ${asyncId}, triggerId: ${triggerId})`);
+ if (asyncId < 0 || triggerAsyncId < 0) {
+ fatalError('before(): asyncId or triggerAsyncId is less than zero ' +
+ `(asyncId: ${asyncId}, triggerAsyncId: ${triggerAsyncId})`);
}
- pushAsyncIds(asyncId, triggerId);
+ pushAsyncIds(asyncId, triggerAsyncId);
if (async_hook_fields[kBefore] === 0)
return;
@@ -446,13 +458,16 @@ function emitDestroyN(asyncId) {
// change in the future depending on whether it can be determined if there's a
// slim chance of the application remaining stable after handling one of these
// exceptions.
-function init(asyncId, type, triggerId, resource) {
+function init(asyncId, type, triggerAsyncId, resource) {
processing_hook = true;
// Use a single try/catch for all hook to avoid setting up one per iteration.
try {
for (var i = 0; i < active_hooks_array.length; i++) {
if (typeof active_hooks_array[i][init_symbol] === 'function') {
- active_hooks_array[i][init_symbol](asyncId, type, triggerId, resource);
+ active_hooks_array[i][init_symbol](
+ asyncId, type, triggerAsyncId,
+ resource
+ );
}
}
} catch (e) {
@@ -467,8 +482,8 @@ function init(asyncId, type, triggerId, resource) {
module.exports = {
// Public API
createHook,
- currentId,
- triggerId,
+ executionAsyncId,
+ triggerAsyncId,
// Embedder API
AsyncResource,
runInAsyncIdScope,
@@ -481,3 +496,23 @@ module.exports = {
emitAfter: emitAfterS,
emitDestroy: emitDestroyS,
};
+
+// currentId was renamed to executionAsyncId. This was in 8.2.0 during the
+// experimental stage so the alias can be removed at any time, we are just
+// being nice :)
+Object.defineProperty(module.exports, 'currentId', {
+ get: internalUtil.deprecate(function() {
+ return executionAsyncId;
+ }, 'async_hooks.currentId is deprecated. ' +
+ 'Use async_hooks.executionAsyncId instead.', 'DEP0070')
+});
+
+// triggerId was renamed to triggerAsyncId. This was in 8.2.0 during the
+// experimental stage so the alias can be removed at any time, we are just
+// being nice :)
+Object.defineProperty(module.exports, 'triggerId', {
+ get: internalUtil.deprecate(function() {
+ return triggerAsyncId;
+ }, 'async_hooks.triggerId is deprecated. ' +
+ 'Use async_hooks.triggerAsyncId instead.', 'DEP0071')
+});
diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js
index 0ba26ce033e6ff..61756f603cd0e6 100644
--- a/lib/internal/process/next_tick.js
+++ b/lib/internal/process/next_tick.js
@@ -114,11 +114,11 @@ function setupNextTick() {
// is much slower here than was the Float64Array stack used in a previous
// implementation. Problem is the Float64Array stack was a bit brittle.
// Investigate how to harden that implementation and possibly reintroduce it.
- function nextTickEmitBefore(asyncId, triggerId) {
+ function nextTickEmitBefore(asyncId, triggerAsyncId) {
if (async_hook_fields[kBefore] > 0)
- emitBefore(asyncId, triggerId);
+ emitBefore(asyncId, triggerAsyncId);
else
- pushAsyncIds(asyncId, triggerId);
+ pushAsyncIds(asyncId, triggerAsyncId);
}
function nextTickEmitAfter(asyncId) {
@@ -218,9 +218,9 @@ function setupNextTick() {
this[trigger_id_symbol] = -1;
}
- function setupInit(tickObject, triggerId) {
+ function setupInit(tickObject, triggerAsyncId) {
tickObject[async_id_symbol] = ++async_uid_fields[kAsyncUidCntr];
- tickObject[trigger_id_symbol] = triggerId || initTriggerId();
+ tickObject[trigger_id_symbol] = triggerAsyncId || initTriggerId();
if (async_hook_fields[kInit] > 0) {
emitInit(tickObject[async_id_symbol],
'TickObject',
@@ -249,11 +249,11 @@ function setupNextTick() {
tickInfo[kLength]++;
}
- function internalNextTick(triggerId, callback) {
+ function internalNextTick(triggerAsyncId, callback) {
if (typeof callback !== 'function')
throw new TypeError('callback is not a function');
- // CHECK(Number.isSafeInteger(triggerId) || triggerId === null)
- // CHECK(triggerId > 0 || triggerId === null)
+ // CHECK(Number.isSafeInteger(triggerAsyncId) || triggerAsyncId === null)
+ // CHECK(triggerAsyncId > 0 || triggerAsyncId === null)
if (process._exiting)
return;
@@ -266,7 +266,7 @@ function setupNextTick() {
}
var obj = new TickObject(callback, args, process.domain || null);
- setupInit(obj, triggerId);
+ setupInit(obj, triggerAsyncId);
// The call to initTriggerId() was skipped, so clear kInitTriggerId.
async_uid_fields[kInitTriggerId] = 0;
nextTickQueue.push(obj);
diff --git a/lib/timers.js b/lib/timers.js
index dd650d3c9acd56..13c55322ec628a 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -43,7 +43,7 @@ const { kInit, kBefore, kAfter, kDestroy, kAsyncUidCntr } =
async_wrap.constants;
// Symbols for storing async id state.
const async_id_symbol = Symbol('asyncId');
-const trigger_id_symbol = Symbol('triggerId');
+const trigger_id_symbol = Symbol('triggerAsyncId');
// Timeout values > TIMEOUT_MAX are set to 1.
const TIMEOUT_MAX = 2147483647; // 2^31-1
@@ -149,11 +149,11 @@ exports._unrefActive = function(item) {
};
-function timerEmitBefore(asyncId, triggerId) {
+function timerEmitBefore(asyncId, triggerAsyncId) {
if (async_hook_fields[kBefore] > 0)
- emitBefore(asyncId, triggerId);
+ emitBefore(asyncId, triggerAsyncId);
else
- pushAsyncIds(asyncId, triggerId);
+ pushAsyncIds(asyncId, triggerAsyncId);
}
diff --git a/src/async-wrap.cc b/src/async-wrap.cc
index d7cdc4198c944b..4d357f2f41b7ef 100644
--- a/src/async-wrap.cc
+++ b/src/async-wrap.cc
@@ -350,11 +350,11 @@ static void PromiseHook(PromiseHookType type, Local promise,
bool silent = type != PromiseHookType::kInit;
PromiseWrap* parent_wrap = nullptr;
- // set parent promise's async Id as this promise's triggerId
+ // set parent promise's async Id as this promise's triggerAsyncId
if (parent->IsPromise()) {
// parent promise exists, current promise
// is a chained promise, so we set parent promise's id as
- // current promise's triggerId
+ // current promise's triggerAsyncId
Local parent_promise = parent.As();
Local parent_resource = parent_promise->GetInternalField(0);
if (parent_resource->IsObject()) {
@@ -731,15 +731,23 @@ Local AsyncWrap::MakeCallback(const Local cb,
/* Public C++ embedder API */
-async_uid AsyncHooksGetCurrentId(Isolate* isolate) {
+async_uid AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
return Environment::GetCurrent(isolate)->current_async_id();
}
+async_uid AsyncHooksGetCurrentId(Isolate* isolate) {
+ return AsyncHooksGetExecutionAsyncId(isolate);
+}
-async_uid AsyncHooksGetTriggerId(Isolate* isolate) {
+
+async_uid AsyncHooksGetTriggerAsyncId(Isolate* isolate) {
return Environment::GetCurrent(isolate)->get_init_trigger_id();
}
+async_uid AsyncHooksGetTriggerId(Isolate* isolate) {
+ return AsyncHooksGetTriggerAsyncId(isolate);
+}
+
async_uid EmitAsyncInit(Isolate* isolate,
Local