diff --git a/src/builtins/internal_js_modules/node/async_hooks.js b/src/builtins/internal_js_modules/node/async_hooks.js index eefb605ab..eb0cedfa4 100644 --- a/src/builtins/internal_js_modules/node/async_hooks.js +++ b/src/builtins/internal_js_modules/node/async_hooks.js @@ -249,6 +249,15 @@ export class AsyncLocalStorage { const currentFrame = AsyncContextFrame.current(); return currentFrame.get(this.#key); } + static bind(fn) { + return AsyncResource.bind(fn); + } + static snapshot() { + return AsyncLocalStorage.bind(( + cb, + ...args + ) => cb(...args)); + } } export function executionAsyncId() { return 1; diff --git a/src/builtins/internal_js_modules/node/async_hooks.ts b/src/builtins/internal_js_modules/node/async_hooks.ts index 94cf1cb05..449f6c3b3 100644 --- a/src/builtins/internal_js_modules/node/async_hooks.ts +++ b/src/builtins/internal_js_modules/node/async_hooks.ts @@ -313,6 +313,17 @@ export class AsyncLocalStorage { const currentFrame = AsyncContextFrame.current(); return currentFrame.get(this.#key); } + + static bind(fn: (...args: unknown[]) => unknown) { + return AsyncResource.bind(fn); + } + + static snapshot() { + return AsyncLocalStorage.bind(( + cb: (...args: unknown[]) => unknown, + ...args: unknown[] + ) => cb(...args)); + } } export function executionAsyncId() {