File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,6 @@ const EE = require('events')
51
51
const { Readable, pipeline } = require ( 'stream' )
52
52
const { isErrored, isReadable } = require ( '../core/util' )
53
53
const { dataURLProcessor } = require ( './dataURL' )
54
- const { kIsMockActive } = require ( '../mock/mock-symbols' )
55
54
const { TransformStream } = require ( 'stream/web' )
56
55
57
56
/** @type {import('buffer').resolveObjectURL } */
@@ -1912,7 +1911,7 @@ async function httpNetworkFetch (
1912
1911
path : url . pathname + url . search ,
1913
1912
origin : url . origin ,
1914
1913
method : request . method ,
1915
- body : fetchParams . controller . dispatcher [ kIsMockActive ] ? request . body && request . body . source : body ,
1914
+ body : fetchParams . controller . dispatcher . isActive ? request . body && request . body . source : body ,
1916
1915
headers : [ ...request . headersList ] . flat ( ) ,
1917
1916
maxRedirections : 0 ,
1918
1917
bodyTimeout : 300_000 ,
Original file line number Diff line number Diff line change @@ -96,6 +96,12 @@ class MockAgent extends Dispatcher {
96
96
this [ kNetConnect ] = false
97
97
}
98
98
99
+ // This is required to bypass issues caused by using global symbols - see:
100
+ // https://github.com/nodejs/undici/issues/1447
101
+ get isActive ( ) {
102
+ return this [ kIsMockActive ]
103
+ }
104
+
99
105
[ kMockAgentSet ] ( origin , dispatcher ) {
100
106
this [ kClients ] . set ( origin , new FakeWeakRef ( dispatcher ) )
101
107
}
Original file line number Diff line number Diff line change 6
6
kMockAgent,
7
7
kOriginalDispatch,
8
8
kOrigin,
9
- kIsMockActive,
10
9
kGetNetConnect
11
10
} = require ( './mock-symbols' )
12
11
@@ -302,7 +301,7 @@ function buildMockDispatch () {
302
301
const originalDispatch = this [ kOriginalDispatch ]
303
302
304
303
return function dispatch ( opts , handler ) {
305
- if ( agent [ kIsMockActive ] ) {
304
+ if ( agent . isActive ) {
306
305
try {
307
306
mockDispatch . call ( this , opts , handler )
308
307
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments