@@ -4,6 +4,7 @@ const sinon = require('sinon')
4
4
const chai = require ( 'chai' )
5
5
const sinonChai = require ( 'sinon-chai' )
6
6
const proxyquire = require ( '../proxyquire' )
7
+ const { NODE_MAJOR } = require ( '../../../../version' )
7
8
8
9
{
9
10
// get-port can often return a port that is already in use, thanks to a race
@@ -48,3 +49,35 @@ if (/^v\d+\.x$/.test(process.env.GITHUB_BASE_REF || '')) {
48
49
process . env . DD_INJECTION_ENABLED = 'true'
49
50
process . env . DD_INJECT_FORCE = 'true'
50
51
}
52
+
53
+ // TODO(bengl): remove this block once we can properly support Node.js 24 without it
54
+ if ( NODE_MAJOR >= 24 && ! process . env . OPTIONS_OVERRIDE ) {
55
+ const childProcess = require ( 'child_process' )
56
+ const { exec, fork } = childProcess
57
+
58
+ childProcess . exec = function ( ...args ) {
59
+ const opts = args [ 1 ]
60
+ if ( opts ) {
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'
66
+ }
67
+ }
68
+ return exec . apply ( this , args )
69
+ }
70
+
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 )
82
+ }
83
+ }
0 commit comments