Skip to content

Commit f2e8cb3

Browse files
committed
Revert "simpler adding --no-async-context-frame (#5717)"
This reverts commit fcf95b2.
1 parent 295edf4 commit f2e8cb3

File tree

1 file changed

+18
-12
lines changed
  • packages/dd-trace/test/setup

1 file changed

+18
-12
lines changed

packages/dd-trace/test/setup/core.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,29 @@ if (NODE_MAJOR >= 24 && !process.env.OPTIONS_OVERRIDE) {
5555
const childProcess = require('child_process')
5656
const { exec, fork } = childProcess
5757

58-
function addAsyncContextFrame (fn, thisArg, args) {
58+
childProcess.exec = function (...args) {
5959
const opts = args[1]
6060
if (opts) {
61-
const env = opts.env ||= {}
62-
env.NODE_OPTIONS ||= ''
63-
if (!env.NODE_OPTIONS.includes('--no-async-context-frame')) {
64-
env.NODE_OPTIONS += ' --no-async-context-frame'
61+
if (opts?.env?.NODE_OPTIONS && !opts.env.NODE_OPTIONS.includes('--no-async-context-frame')) {
62+
opts.env.NODE_OPTIONS += ' --no-async-context-frame'
63+
} else {
64+
opts.env ||= {}
65+
opts.env.NODE_OPTIONS = '--no-async-context-frame'
6566
}
6667
}
67-
return fn.apply(thisArg, args)
68+
return exec.apply(this, args)
6869
}
6970

70-
childProcess.exec = function () {
71-
return addAsyncContextFrame(exec, this, arguments)
72-
}
73-
74-
childProcess.fork = function () {
75-
return addAsyncContextFrame(fork, this, arguments)
71+
childProcess.fork = function (...args) {
72+
const opts = args[1]
73+
if (opts) {
74+
if (opts?.env?.NODE_OPTIONS && !opts.env.NODE_OPTIONS.includes('--no-async-context-frame')) {
75+
opts.env.NODE_OPTIONS += ' --no-async-context-frame'
76+
} else {
77+
opts.env ||= {}
78+
opts.env.NODE_OPTIONS = '--no-async-context-frame'
79+
}
80+
}
81+
return fork.apply(this, args)
7682
}
7783
}

0 commit comments

Comments
 (0)