Skip to content

Commit 5f43ff6

Browse files
committed
Test the async context frame with Node 23 and later
1 parent 13c325f commit 5f43ff6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

integration-tests/profiler/profiler.spec.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const fsync = require('fs')
1313
const net = require('net')
1414
const zlib = require('zlib')
1515
const { Profile } = require('pprof-format')
16+
const satisfies = require('semifies')
1617

1718
const DEFAULT_PROFILE_TYPES = ['wall', 'space']
1819
if (process.platform !== 'win32') {
@@ -329,15 +330,23 @@ describe('profiler', () => {
329330
// with recomputed busyCycleTimeNs, but let's give ourselves more leeway.
330331
this.retries(9)
331332
const procStart = BigInt(Date.now() * 1000000)
332-
const proc = fork(path.join(cwd, 'profiler/codehotspots.js'), {
333-
cwd,
334-
env: {
335-
DD_PROFILING_EXPORTERS: 'file',
336-
DD_PROFILING_ENABLED: 1,
337-
BUSY_CYCLE_TIME: (busyCycleTimeNs | 0).toString(),
338-
DD_TRACE_AGENT_PORT: agent.port
333+
const env = {
334+
DD_PROFILING_EXPORTERS: 'file',
335+
DD_PROFILING_ENABLED: 1,
336+
BUSY_CYCLE_TIME: (busyCycleTimeNs | 0).toString(),
337+
DD_TRACE_AGENT_PORT: agent.port
338+
}
339+
// With Node 23 or later, test the profiler with async context frame use.
340+
let execArgv = []
341+
if (satisfies(process.versions.node, '>=23.0.0')) {
342+
env.DD_PROFILING_USE_ASYNC_CONTEXT_FRAME = 1
343+
if (!satisfies(process.versions.node, '>=24.0.0')) {
344+
// For Node 23, use the experimental command line flag for Node to enable
345+
// async context frame. Node 24 has it enabled by default.
346+
execArgv = ['--experimental-async-context-frame']
339347
}
340-
})
348+
}
349+
const proc = fork(path.join(cwd, 'profiler/codehotspots.js'), { cwd, env, execArgv })
341350

342351
await processExitPromise(proc, timeout)
343352
const procEnd = BigInt(Date.now() * 1000000)

0 commit comments

Comments
 (0)