Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions bindings/profilers/wall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,25 @@ struct TimeTicks {
static int64_t Now();
};
} // namespace base
#if NODE_MAJOR_VERSION >= 24
#if NODE_MAJOR_VERSION >= 22

// Available from 22.7.0
#define DD_WALL_USE_CPED true

namespace internal {
#if NODE_MAJOR_VERSION == 24
#if NODE_MAJOR_VERSION < 25
struct HandleScopeData {
v8::internal::Address* next;
v8::internal::Address* limit;
};
#endif
#endif // NODE_MAJOR_VERSION < 25
#if NODE_MAJOR_VERSION >= 24
constexpr int kHandleBlockSize = v8::internal::KB - 2;
#endif // NODE_MAJOR_VERSION >= 24
} // namespace internal
#endif
#else // NODE_MAJOR_VERSION >= 22
#define DD_WALL_USE_CPED false
#endif //
} // namespace v8

static int64_t Now() {
Expand All @@ -61,18 +69,14 @@ static int64_t Now() {

#else
#define DD_WALL_USE_SIGPROF false
#define DD_WALL_USE_CPED false

static int64_t Now() {
return 0;
};

#endif

#if NODE_MAJOR_VERSION >= 23
#define DD_WALL_USE_CPED true
#else
#define DD_WALL_USE_CPED false
#endif

using namespace v8;

namespace dd {
Expand Down Expand Up @@ -905,7 +909,12 @@ NAN_METHOD(WallProfiler::New) {
#if !DD_WALL_USE_CPED
if (useCPED) {
return Nan::ThrowTypeError(
"useCPED is not supported on this Node.js version.");
#ifndef _WIN32
"useCPED is not supported on this Node.js version."
#else
"useCPED is not supported on Windows."
#endif
);
}
#endif

Expand Down
1 change: 0 additions & 1 deletion ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const time = {
v8ProfilerStuckEventLoopDetected:
timeProfiler.v8ProfilerStuckEventLoopDetected,
getState: timeProfiler.getState,
getMetrics: timeProfiler.getMetrics,
constants: timeProfiler.constants,
};

Expand Down
6 changes: 4 additions & 2 deletions ts/test/test-time-profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ import {satisfies} from 'semver';
import assert from 'assert';

const useCPED =
satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame');
(satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame')) ||
(satisfies(process.versions.node, '>=22.7.0') &&
process.execArgv.includes('--experimental-async-context-frame'));

const collectAsyncId = satisfies(process.versions.node, '>=24.0.0');

Expand Down
7 changes: 5 additions & 2 deletions ts/test/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ const intervalMicros = 10000;
const withContexts =
process.platform === 'darwin' || process.platform === 'linux';
const useCPED =
satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame');
withContexts &&
((satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame')) ||
(satisfies(process.versions.node, '>=22.7.0') &&
process.execArgv.includes('--experimental-async-context-frame')));
const collectAsyncId =
withContexts && satisfies(process.versions.node, '>=24.0.0');

Expand Down
7 changes: 5 additions & 2 deletions ts/test/worker2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ const withContexts =
process.platform === 'darwin' || process.platform === 'linux';

const useCPED =
satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame');
withContexts &&
((satisfies(process.versions.node, '>=24.0.0') &&
!process.execArgv.includes('--no-async-context-frame')) ||
(satisfies(process.versions.node, '>=22.7.0') &&
process.execArgv.includes('--experimental-async-context-frame')));

const collectAsyncId =
withContexts && satisfies(process.versions.node, '>=24.0.0');
Expand Down