@platformatic/foundation 3.55.0 → 3.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/node.js +29 -3
- package/package.json +1 -1
package/lib/node.js
CHANGED
|
@@ -26,14 +26,18 @@ export function checkNodeVersionForApplications () {
|
|
|
26
26
|
which undici version Node bundles. This can be dropped once undici aligns the
|
|
27
27
|
symbols across versions: https://github.com/nodejs/undici/pull/5319
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
const kMirroredGlobalDispatcher = Symbol.for('platformatic.undici.mirroredGlobalDispatcher')
|
|
30
|
+
const kMirroredLegacyGlobalDispatcher = Symbol.for('platformatic.undici.mirroredLegacyGlobalDispatcher')
|
|
31
|
+
|
|
32
|
+
export function mirrorGlobalDispatcherForBuiltinFetch (dispatcher, legacyDispatcher = dispatcher) {
|
|
30
33
|
for (const version of [1, 2]) {
|
|
31
34
|
const symbol = Symbol.for(`undici.globalDispatcher.${version}`)
|
|
32
35
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, symbol)
|
|
36
|
+
const value = version === 1 ? legacyDispatcher : dispatcher
|
|
33
37
|
|
|
34
38
|
if (!descriptor) {
|
|
35
39
|
Object.defineProperty(globalThis, symbol, {
|
|
36
|
-
value
|
|
40
|
+
value,
|
|
37
41
|
writable: true,
|
|
38
42
|
enumerable: false,
|
|
39
43
|
configurable: false
|
|
@@ -41,9 +45,31 @@ export function mirrorGlobalDispatcherForBuiltinFetch (dispatcher) {
|
|
|
41
45
|
} else if (descriptor.writable) {
|
|
42
46
|
// The symbol is created as non-configurable but writable, so a plain
|
|
43
47
|
// assignment is the only legal way to update an already-defined slot.
|
|
44
|
-
globalThis[symbol] =
|
|
48
|
+
globalThis[symbol] = value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
globalThis[kMirroredGlobalDispatcher] = dispatcher
|
|
53
|
+
globalThis[kMirroredLegacyGlobalDispatcher] = legacyDispatcher
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getGlobalDispatcherFromKnownUndiciSymbols () {
|
|
57
|
+
const mirroredDispatcher = globalThis[kMirroredGlobalDispatcher]
|
|
58
|
+
const mirroredLegacyDispatcher = globalThis[kMirroredLegacyGlobalDispatcher]
|
|
59
|
+
const legacyDispatcher = globalThis[Symbol.for('undici.globalDispatcher.1')]
|
|
60
|
+
const dispatcher = globalThis[Symbol.for('undici.globalDispatcher.2')]
|
|
61
|
+
|
|
62
|
+
if (mirroredDispatcher) {
|
|
63
|
+
if (dispatcher && dispatcher !== mirroredDispatcher) {
|
|
64
|
+
return dispatcher
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (legacyDispatcher && legacyDispatcher !== (mirroredLegacyDispatcher ?? mirroredDispatcher)) {
|
|
68
|
+
return legacyDispatcher
|
|
45
69
|
}
|
|
46
70
|
}
|
|
71
|
+
|
|
72
|
+
return dispatcher ?? legacyDispatcher
|
|
47
73
|
}
|
|
48
74
|
|
|
49
75
|
export const features = {
|