undici 8.0.0 → 8.0.1
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/README.md
CHANGED
|
@@ -621,7 +621,7 @@ including undici that is bundled internally with node.js.
|
|
|
621
621
|
|
|
622
622
|
Undici stores this dispatcher under `Symbol.for('undici.globalDispatcher.2')`.
|
|
623
623
|
|
|
624
|
-
|
|
624
|
+
`setGlobalDispatcher()` also mirrors the configured dispatcher to
|
|
625
625
|
`Symbol.for('undici.globalDispatcher.1')` using `Dispatcher1Wrapper`, so Node.js built-in `fetch`
|
|
626
626
|
can keep using the legacy handler contract while Undici uses the new handler API.
|
|
627
627
|
|
|
@@ -237,7 +237,7 @@ Pause/resume now uses the controller:
|
|
|
237
237
|
Undici now stores the global dispatcher under `Symbol.for('undici.globalDispatcher.2')`.
|
|
238
238
|
This avoids conflicts with runtimes (such as Node.js built-in `fetch`) that still rely on the legacy dispatcher handler interface.
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
`setGlobalDispatcher()` also mirrors the configured dispatcher to `Symbol.for('undici.globalDispatcher.1')` using a `Dispatcher1Wrapper`, so Node's built-in `fetch` can keep using the legacy handler contract.
|
|
241
241
|
|
|
242
242
|
If you need to expose a new dispatcher/agent to legacy v1 handler consumers (`onConnect/onHeaders/onData/onComplete/onError/onUpgrade`), use `Dispatcher1Wrapper`:
|
|
243
243
|
|
|
@@ -23,7 +23,6 @@ Returns: `ProxyAgent`
|
|
|
23
23
|
- **minTimeout** `number` (optional) - Minimum number of milliseconds to wait before retrying. Default: `500` (half a second)
|
|
24
24
|
- **timeoutFactor** `number` (optional) - Factor to multiply the timeout by for each retry attempt. Default: `2`
|
|
25
25
|
- **retryAfter** `boolean` (optional) - It enables automatic retry after the `Retry-After` header is received. Default: `true`
|
|
26
|
-
-
|
|
27
26
|
- **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE']`
|
|
28
27
|
- **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
|
|
29
28
|
- **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN','ENETUNREACH', 'EHOSTDOWN', 'UND_ERR_SOCKET']`
|
|
@@ -26,7 +26,6 @@ Extends: [`Dispatch.DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dis
|
|
|
26
26
|
- **minTimeout** `number` (optional) - Minimum number of milliseconds to wait before retrying. Default: `500` (half a second)
|
|
27
27
|
- **timeoutFactor** `number` (optional) - Factor to multiply the timeout by for each retry attempt. Default: `2`
|
|
28
28
|
- **retryAfter** `boolean` (optional) - It enables automatic retry after the `Retry-After` header is received. Default: `true`
|
|
29
|
-
-
|
|
30
29
|
- **methods** `string[]` (optional) - Array of HTTP methods to retry. Default: `['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE']`
|
|
31
30
|
- **statusCodes** `number[]` (optional) - Array of HTTP status codes to retry. Default: `[429, 500, 502, 503, 504]`
|
|
32
31
|
- **errorCodes** `string[]` (optional) - Array of Error codes to retry. Default: `['ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN','ENETUNREACH', 'EHOSTDOWN', 'UND_ERR_SOCKET']`
|
package/lib/global.js
CHANGED
|
@@ -8,8 +8,6 @@ const { InvalidArgumentError } = require('./core/errors')
|
|
|
8
8
|
const Agent = require('./dispatcher/agent')
|
|
9
9
|
const Dispatcher1Wrapper = require('./dispatcher/dispatcher1-wrapper')
|
|
10
10
|
|
|
11
|
-
const nodeMajor = Number(process.versions.node.split('.', 1)[0])
|
|
12
|
-
|
|
13
11
|
if (getGlobalDispatcher() === undefined) {
|
|
14
12
|
setGlobalDispatcher(new Agent())
|
|
15
13
|
}
|
|
@@ -26,16 +24,14 @@ function setGlobalDispatcher (agent) {
|
|
|
26
24
|
configurable: false
|
|
27
25
|
})
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent)
|
|
27
|
+
const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent)
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
29
|
+
Object.defineProperty(globalThis, legacyGlobalDispatcher, {
|
|
30
|
+
value: legacyAgent,
|
|
31
|
+
writable: true,
|
|
32
|
+
enumerable: false,
|
|
33
|
+
configurable: false
|
|
34
|
+
})
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
function getGlobalDispatcher () {
|
|
@@ -284,12 +284,6 @@ class WebSocketStream {
|
|
|
284
284
|
start: (controller) => {
|
|
285
285
|
this.#readableStreamController = controller
|
|
286
286
|
},
|
|
287
|
-
pull (controller) {
|
|
288
|
-
let chunk
|
|
289
|
-
while (controller.desiredSize > 0 && (chunk = response.socket.read()) !== null) {
|
|
290
|
-
controller.enqueue(chunk)
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
287
|
cancel: (reason) => this.#cancel(reason)
|
|
294
288
|
})
|
|
295
289
|
|