Skip to content

Commit 2e4f511

Browse files
Flarnasheetalkamat
authored andcommitted
[node] Update async_hooks according to renaming done in 8.2.0 (#18530)
- currentId() => executionAsyncId() - triggerId() => triggerAsyncId() see nodejs/node#13490
1 parent 47ce03d commit 2e4f511

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,22 +5748,26 @@ declare module "async_hooks" {
57485748
/**
57495749
* Returns the asyncId of the current execution context.
57505750
*/
5751+
export function executionAsyncId(): number;
5752+
/// @deprecated - replaced by executionAsyncId()
57515753
export function currentId(): number;
57525754

57535755
/**
57545756
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
57555757
*/
5758+
export function triggerAsyncId(): number;
5759+
/// @deprecated - replaced by triggerAsyncId()
57565760
export function triggerId(): number;
57575761

57585762
export interface HookCallbacks {
57595763
/**
57605764
* Called when a class is constructed that has the possibility to emit an asynchronous event.
57615765
* @param asyncId a unique ID for the async resource
57625766
* @param type the type of the async resource
5763-
* @param triggerId the unique ID of the async resource in whose execution context this async resource was created
5767+
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
57645768
* @param resource reference to the resource representing the async operation, needs to be released during destroy
57655769
*/
5766-
init?(asyncId: number, type: string, triggerId: number, resource: Object): void;
5770+
init?(asyncId: number, type: string, triggerAsyncId: number, resource: Object): void;
57675771

57685772
/**
57695773
* When an asynchronous operation is initiated or completes a callback is called to notify the user.

node-tests.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,7 @@ client.listbreakpoints((err, body, packet) => { });
28012801
////////////////////////////////////////////////////
28022802
namespace async_hooks_tests {
28032803
const hooks: async_hooks.HookCallbacks = {
2804-
init: (asyncId: number, type: string, triggerId: number, resource: object) => void {},
2804+
init: (asyncId: number, type: string, triggerAsyncId: number, resource: object) => void {},
28052805
before: (asyncId: number) => void {},
28062806
after: (asyncId: number) => void {},
28072807
destroy: (asyncId: number) => void {}
@@ -2810,4 +2810,7 @@ namespace async_hooks_tests {
28102810
const asyncHook = async_hooks.createHook(hooks);
28112811

28122812
asyncHook.enable().disable().enable();
2813+
2814+
const tId: number = async_hooks.triggerAsyncId();
2815+
const eId: number = async_hooks.executionAsyncId();
28132816
}

0 commit comments

Comments
 (0)