|
|
@@ -44,6 +44,17 @@ function childFetch(target: string, env: Record<string, string>): Promise<string
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * Whether this runtime honors `NODE_USE_ENV_PROXY`, which is how a separate Node execution context
|
|
|
+ * receives the policy. Added in Node 24.0 and backported to 22.21; the engines range admits 22.19
|
|
|
+ * and 22.20, where such a context stays direct.
|
|
|
+ */
|
|
|
+function supportsEnvProxy(): boolean {
|
|
|
+ const [major = 0, minor = 0] = process.versions.node.split('.').map(Number)
|
|
|
+ return major >= 24 || (major === 22 && minor >= 21)
|
|
|
+}
|
|
|
+
|
|
|
describe('child process egress', () => {
|
|
|
it('a child Node honors the parent policy through scrubbedParentEnv', async () => {
|
|
|
let childEnv: Record<string, string> = {}
|
|
|
@@ -52,6 +63,9 @@ describe('child process egress', () => {
|
|
|
await childFetch('http://child-probe.invalid/x', childEnv)
|
|
|
})
|
|
|
expect(childEnv.NODE_USE_ENV_PROXY).toBe('1')
|
|
|
- expect(observed.join('|')).toContain('child-probe.invalid')
|
|
|
+ // The flag is what a child Node acts on; an older runtime ignores it and stays direct, which is
|
|
|
+ // the documented seam rather than a defect.
|
|
|
+ if (supportsEnvProxy()) expect(observed.join('|')).toContain('child-probe.invalid')
|
|
|
+ else expect(observed).toEqual([])
|
|
|
})
|
|
|
})
|