Skip to content

Commit bfa2637

Browse files
authored
Use AsyncHooksGetExecutionAsyncId(Context) API on Node 24 (#210)
1 parent 55ac3fa commit bfa2637

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

bindings/profilers/wall.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,13 @@ NAN_METHOD(WallProfiler::Dispose) {
10211021
}
10221022

10231023
double GetAsyncIdNoGC(v8::Isolate* isolate) {
1024-
return isolate->InContext() ? node::AsyncHooksGetExecutionAsyncId(isolate)
1025-
: -1;
1024+
#if NODE_MAJOR_VERSION >= 24
1025+
HandleScope scope(isolate);
1026+
auto context = isolate->GetEnteredOrMicrotaskContext();
1027+
return context.IsEmpty() ? -1 : node::AsyncHooksGetExecutionAsyncId(context);
1028+
#else
1029+
return node::AsyncHooksGetExecutionAsyncId(isolate);
1030+
#endif
10261031
}
10271032

10281033
double WallProfiler::GetAsyncId(v8::Isolate* isolate) {

0 commit comments

Comments
 (0)