Skip to main content
AsyncResource.prototype.runInAsyncScope - node__async_hooks.d.ts - Node documentation
method AsyncResource.prototype.runInAsyncScope

Usage in Deno

```typescript import { AsyncResource } from "node:node__async_hooks.d.ts"; ```
AsyncResource.prototype.runInAsyncScope<
This,
Result,
>
(
fn: (
this: This,
...args: any[],
) => Result
,
thisArg?: This,
...args: any[],
): Result
Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks before callbacks, call the function, trigger the AsyncHooks after callbacks, and then restore the original execution context.

Type Parameters

This
Result

Parameters

fn: (
this: This,
...args: any[],
) => Result
The function to call in the execution context of this async resource.
optional
thisArg: This
The receiver to be used for the function call.
...args: any[]

Return Type