Skip to content

Commit 2b9041d

Browse files
committed
CPED features need at least Node 23
1 parent cc2e8da commit 2b9041d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bindings/profilers/wall.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ WallProfiler::WallProfiler(std::chrono::microseconds samplingPeriod,
531531
workaroundV8Bug_ = workaroundV8Bug && DD_WALL_USE_SIGPROF && detectV8Bug_;
532532
collectCpuTime_ = collectCpuTime && withContexts;
533533
collectAsyncId_ = collectAsyncId && withContexts;
534+
#if NODE_MAJOR_VERSION >= 23
535+
useCPED_ = useCPED && withContexts;
536+
#else
537+
useCPED_ = false;
538+
#endif
534539

535540
if (withContexts_) {
536541
contexts_.reserve(duration * 2 / samplingPeriod);
@@ -628,6 +633,12 @@ NAN_METHOD(WallProfiler::New) {
628633
DD_WALL_PROFILER_GET_BOOLEAN_CONFIG(isMainThread);
629634
DD_WALL_PROFILER_GET_BOOLEAN_CONFIG(useCPED);
630635

636+
#if NODE_MAJOR_VERSION < 23
637+
if (useCPED) {
638+
return Nan::ThrowTypeError("useCPED is not supported on this Node.js version.");
639+
}
640+
#endif
641+
631642
if (withContexts && !DD_WALL_USE_SIGPROF) {
632643
return Nan::ThrowTypeError("Contexts are not supported.");
633644
}
@@ -1015,6 +1026,7 @@ class PersistentContextPtr : AtomicContextPtr {
10151026
};
10161027

10171028
void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
1029+
#if NODE_MAJOR_VERSION >= 23
10181030
if (!useCPED_) {
10191031
curContext_.Set(isolate, value);
10201032
return;
@@ -1048,6 +1060,9 @@ void WallProfiler::SetContext(Isolate* isolate, Local<Value> value) {
10481060
}
10491061

10501062
contextPtr->Set(isolate, value);
1063+
#else
1064+
curContext_.Set(isolate, value);
1065+
#endif
10511066
}
10521067

10531068
ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
@@ -1070,6 +1085,7 @@ ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
10701085
}
10711086

10721087
ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
1088+
#if NODE_MAJOR_VERSION >= 23
10731089
if (!useCPED_) {
10741090
return curContext_.Get();
10751091
}
@@ -1087,6 +1103,9 @@ ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
10871103

10881104
return static_cast<PersistentContextPtr*>(profData.As<External>()->Value())
10891105
->Get();
1106+
#else
1107+
return curContext_.Get();
1108+
#endif
10901109
}
10911110

10921111
NAN_GETTER(WallProfiler::GetContext) {

0 commit comments

Comments
 (0)