@nxtedition/nxt-undici 7.1.8 → 7.1.11
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/index.js
CHANGED
|
@@ -161,7 +161,8 @@ export function dispatch(dispatcher, opts, handler) {
|
|
|
161
161
|
* protocol: string?,
|
|
162
162
|
* pathname: string?,
|
|
163
163
|
* search: string?,
|
|
164
|
-
* }}
|
|
164
|
+
* }} URLObject
|
|
165
|
+
* @typedef {string|URL|URLObject} URLLike
|
|
165
166
|
*/
|
|
166
167
|
|
|
167
168
|
/**
|
|
@@ -174,13 +175,13 @@ export function dispatch(dispatcher, opts, handler) {
|
|
|
174
175
|
* id: string | null | undefined,
|
|
175
176
|
* dispatch: function,
|
|
176
177
|
* dispatcher: import('@nxtedition/undici').Dispatcher | null | undefined,
|
|
177
|
-
* url:
|
|
178
|
+
* url: URLLike | null | undefined,
|
|
178
179
|
* origin: string?,
|
|
179
180
|
* path: string?,
|
|
180
181
|
* method: string | null | undefined,
|
|
181
182
|
* body: import('stream').Readable | Uint8Array | string | null | undefined,
|
|
182
183
|
* query: object | null | undefined,
|
|
183
|
-
* headers:
|
|
184
|
+
* headers: Record<string, string> | null | undefined,
|
|
184
185
|
* signal: AbortSignal | null | undefined,
|
|
185
186
|
* reset: boolean | null | undefined,
|
|
186
187
|
* blocking: boolean | null | undefined,
|
|
@@ -204,9 +205,13 @@ export function dispatch(dispatcher, opts, handler) {
|
|
|
204
205
|
|
|
205
206
|
/**
|
|
206
207
|
*
|
|
207
|
-
* @param {
|
|
208
|
+
* @param {URLLike|RequestOptions} urlOrOpts
|
|
208
209
|
* @param {RequestOptions|null} [opts]
|
|
209
|
-
* @returns
|
|
210
|
+
* @returns {Promise<{
|
|
211
|
+
* body: import('stream').Readable,
|
|
212
|
+
* statusCode: number,
|
|
213
|
+
* headers: Record<string, string | string[] | undefined>
|
|
214
|
+
* }>}
|
|
210
215
|
*/
|
|
211
216
|
export function request(urlOrOpts, opts) {
|
|
212
217
|
return _request(
|
|
@@ -272,7 +272,7 @@ class Handler extends DecoratorHandler {
|
|
|
272
272
|
.then((shouldRetry) => {
|
|
273
273
|
if (this.#aborted) {
|
|
274
274
|
this.#maybeError(this.#reason)
|
|
275
|
-
} else if (shouldRetry
|
|
275
|
+
} else if (!shouldRetry || isDisturbed(this.#opts.body)) {
|
|
276
276
|
this.#maybeError(err)
|
|
277
277
|
} else if (!this.#headersSent) {
|
|
278
278
|
this.#opts.logger?.debug({ err, retryCount: this.#retryCount }, 'retry response headers')
|
|
@@ -327,6 +327,7 @@ class Handler extends DecoratorHandler {
|
|
|
327
327
|
retryAfter != null && Number.isFinite(retryAfter)
|
|
328
328
|
? retryAfter
|
|
329
329
|
: Math.min(10e3, retryCount * 1e3)
|
|
330
|
+
this.#opts.logger?.debug({ statusCode, retryAfter, delay, retryCount }, 'retry delay')
|
|
330
331
|
return tp.setTimeout(delay, true, { signal: opts?.signal ?? undefined })
|
|
331
332
|
}
|
|
332
333
|
|
|
@@ -347,12 +348,14 @@ class Handler extends DecoratorHandler {
|
|
|
347
348
|
'UND_ERR_SOCKET',
|
|
348
349
|
].includes(err.code)
|
|
349
350
|
) {
|
|
351
|
+
this.#opts.logger?.debug({ err, retryCount }, 'retry delay')
|
|
350
352
|
return tp.setTimeout(Math.min(10e3, retryCount * 1e3), true, {
|
|
351
353
|
signal: opts?.signal ?? undefined,
|
|
352
354
|
})
|
|
353
355
|
}
|
|
354
356
|
|
|
355
357
|
if (err?.message && ['other side closed'].includes(err.message)) {
|
|
358
|
+
this.#opts.logger?.debug({ err, retryCount }, 'retry delay')
|
|
356
359
|
return tp.setTimeout(Math.min(10e3, retryCount * 1e3), true, {
|
|
357
360
|
signal: opts?.signal ?? undefined,
|
|
358
361
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/nxt-undici",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
"@nxtedition/undici": "^11.1.1",
|
|
13
13
|
"cache-control-parser": "^2.0.6",
|
|
14
14
|
"fast-querystring": "^1.1.2",
|
|
15
|
-
"http-errors": "^2.0.
|
|
15
|
+
"http-errors": "^2.0.1",
|
|
16
16
|
"xxhash-wasm": "^1.1.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^
|
|
20
|
-
"eslint": "^9.
|
|
19
|
+
"@types/node": "^25.0.0",
|
|
20
|
+
"eslint": "^9.39.1",
|
|
21
21
|
"eslint-plugin-n": "^17.21.3",
|
|
22
22
|
"husky": "^9.1.7",
|
|
23
|
-
"lint-staged": "^16.2.
|
|
23
|
+
"lint-staged": "^16.2.7",
|
|
24
24
|
"pinst": "^3.0.0",
|
|
25
|
-
"prettier": "^3.
|
|
25
|
+
"prettier": "^3.7.4",
|
|
26
26
|
"send": "^1.2.0",
|
|
27
|
-
"tap": "^21.
|
|
27
|
+
"tap": "^21.5.0",
|
|
28
28
|
"undici-types": "^7.15.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|