summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-04-15 18:24:42 +0530
committerGitHub <noreply@github.com>2024-04-15 12:54:42 +0000
commitf36a8951a420e34d8189cda5792f5eeaa5ce85b7 (patch)
treeb7eeece07c56d0e5c74735745e536c984a1b5dec /ext/node/polyfills
parent1835b4f06189560eb17a103b8db05e011a7cd799 (diff)
fix(ext/node): add stub for AsyncResource#asyncId() (#23372)
Ref https://github.com/denoland/deno/issues/23263
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/async_hooks.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/node/polyfills/async_hooks.ts b/ext/node/polyfills/async_hooks.ts
index ea0bfb944..e8960c4dc 100644
--- a/ext/node/polyfills/async_hooks.ts
+++ b/ext/node/polyfills/async_hooks.ts
@@ -10,6 +10,7 @@
import { core } from "ext:core/mod.js";
import { op_node_is_promise_rejected } from "ext:core/ops";
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
+import { newAsyncId } from "ext:deno_node/internal/async_hooks.ts";
function assert(cond: boolean) {
if (!cond) throw new Error("Assertion failed");
@@ -180,9 +181,16 @@ class AsyncContextFrame {
export class AsyncResource {
frame: AsyncContextFrame;
type: string;
+ #asyncId: number;
+
constructor(type: string) {
this.type = type;
this.frame = AsyncContextFrame.current();
+ this.#asyncId = newAsyncId();
+ }
+
+ asyncId() {
+ return this.#asyncId;
}
runInAsyncScope(