@nxtedition/nxt-undici 5.0.1 → 5.0.3
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/interceptor/cache.js +1 -1
- package/lib/interceptor/log.js +1 -1
- package/lib/interceptor/lookup.js +1 -1
- package/lib/interceptor/proxy.js +1 -1
- package/lib/interceptor/redirect.js +1 -1
- package/lib/interceptor/request-body-factory.js +1 -1
- package/lib/interceptor/request-id.js +1 -1
- package/lib/interceptor/response-error.js +1 -1
- package/lib/interceptor/response-retry.js +14 -3
- package/lib/interceptor/response-verify.js +1 -1
- package/package.json +8 -33
package/lib/interceptor/cache.js
CHANGED
|
@@ -129,7 +129,7 @@ function makeKey(opts) {
|
|
|
129
129
|
|
|
130
130
|
const DEFAULT_CACHE_STORE = new MemoryCacheStore({ maxSize: 128 * 1024, maxEntrySize: 1024 })
|
|
131
131
|
|
|
132
|
-
export default (
|
|
132
|
+
export default () => (dispatch) => (opts, handler) => {
|
|
133
133
|
if (!opts.cache || opts.upgrade) {
|
|
134
134
|
return dispatch(opts, handler)
|
|
135
135
|
}
|
package/lib/interceptor/log.js
CHANGED
|
@@ -120,5 +120,5 @@ class Handler extends DecoratorHandler {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export default (
|
|
123
|
+
export default () => (dispatch) => (opts, handler) =>
|
|
124
124
|
opts.logger ? dispatch(opts, new Handler(opts, { handler })) : dispatch(opts, handler)
|
package/lib/interceptor/proxy.js
CHANGED
|
@@ -184,5 +184,5 @@ function cleanRequestHeaders(headers, removeContent, unknownOrigin) {
|
|
|
184
184
|
return ret
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
export default (
|
|
187
|
+
export default () => (dispatch) => (opts, handler) =>
|
|
188
188
|
opts.follow ? dispatch(opts, new Handler(opts, { handler, dispatch })) : dispatch(opts, handler)
|
|
@@ -11,7 +11,7 @@ function genReqId() {
|
|
|
11
11
|
return `req-${nextReqId.toString(36)}`
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export default (
|
|
14
|
+
export default () => (dispatch) => (opts, handler) => {
|
|
15
15
|
const id = opts.id ? `${opts.id},${genReqId()}` : genReqId()
|
|
16
16
|
return dispatch(
|
|
17
17
|
{
|
|
@@ -129,7 +129,7 @@ class Handler extends DecoratorHandler {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
export default (
|
|
132
|
+
export default () => (dispatch) => (opts, handler) =>
|
|
133
133
|
opts.error !== false && opts.throwOnError !== false
|
|
134
134
|
? dispatch(opts, new Handler(opts, { handler }))
|
|
135
135
|
: dispatch(opts, handler)
|
|
@@ -31,7 +31,16 @@ class Handler extends DecoratorHandler {
|
|
|
31
31
|
|
|
32
32
|
this.#handler = handler
|
|
33
33
|
this.#dispatch = dispatch
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
if (typeof opts === 'number') {
|
|
36
|
+
this.#opts = { count: opts }
|
|
37
|
+
} else if (typeof opts === 'boolean') {
|
|
38
|
+
this.#opts = null
|
|
39
|
+
} else if (typeof opts === 'object') {
|
|
40
|
+
this.#opts = opts
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error('invalid argument: opts')
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
onConnect(abort) {
|
|
@@ -149,7 +158,7 @@ class Handler extends DecoratorHandler {
|
|
|
149
158
|
return
|
|
150
159
|
}
|
|
151
160
|
|
|
152
|
-
const retryPromise = retryFn(err, this.#retryCount
|
|
161
|
+
const retryPromise = retryFn(err, this.#retryCount, { ...this.#opts.retry })
|
|
153
162
|
if (retryPromise == null) {
|
|
154
163
|
this.#onError(err)
|
|
155
164
|
return
|
|
@@ -164,6 +173,7 @@ class Handler extends DecoratorHandler {
|
|
|
164
173
|
} else if (isDisturbed(this.#opts.body)) {
|
|
165
174
|
this.#onError(this.#error)
|
|
166
175
|
} else if (!this.#headersSent) {
|
|
176
|
+
this.#retryCount++
|
|
167
177
|
this.#opts.logger?.debug({ retryCount: this.#retryCount }, 'retry response headers')
|
|
168
178
|
this.#dispatch(this.#opts, this)
|
|
169
179
|
} else {
|
|
@@ -181,6 +191,7 @@ class Handler extends DecoratorHandler {
|
|
|
181
191
|
},
|
|
182
192
|
}
|
|
183
193
|
|
|
194
|
+
this.#retryCount++
|
|
184
195
|
this.#opts.logger?.debug({ retryCount: this.#retryCount }, 'retry response body')
|
|
185
196
|
this.#dispatch(this.#opts, this)
|
|
186
197
|
}
|
|
@@ -205,7 +216,7 @@ class Handler extends DecoratorHandler {
|
|
|
205
216
|
}
|
|
206
217
|
}
|
|
207
218
|
|
|
208
|
-
export default (
|
|
219
|
+
export default () => (dispatch) => (opts, handler) =>
|
|
209
220
|
// TODO (fix): HEAD, PUT, PATCH, DELETE, OPTIONS?
|
|
210
221
|
opts.retry !== false && opts.method === 'GET' && !opts.upgrade
|
|
211
222
|
? dispatch(opts, new Handler(opts, { handler, dispatch }))
|
|
@@ -81,7 +81,7 @@ class Handler extends DecoratorHandler {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export default (
|
|
84
|
+
export default () => (dispatch) => (opts, handler) =>
|
|
85
85
|
!opts.upgrade && opts.verify !== false
|
|
86
86
|
? dispatch(opts, new Handler(opts, { handler }))
|
|
87
87
|
: dispatch(opts, handler)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/nxt-undici",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,20 +12,17 @@
|
|
|
12
12
|
"cache-control-parser": "^2.0.6",
|
|
13
13
|
"http-errors": "^2.0.0",
|
|
14
14
|
"lru-cache": "^11.0.2",
|
|
15
|
-
"undici": "^
|
|
15
|
+
"undici": "^7.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/node": "^22.
|
|
19
|
-
"eslint": "^
|
|
20
|
-
"eslint-
|
|
21
|
-
"
|
|
22
|
-
"eslint-plugin-import": "^2.31.0",
|
|
23
|
-
"eslint-plugin-n": "^17.13.1",
|
|
24
|
-
"eslint-plugin-promise": "^7.1.0",
|
|
25
|
-
"husky": "^9.1.6",
|
|
18
|
+
"@types/node": "^22.10.1",
|
|
19
|
+
"eslint": "^9.16.0",
|
|
20
|
+
"eslint-plugin-n": "^17.14.0",
|
|
21
|
+
"husky": "^9.1.7",
|
|
26
22
|
"lint-staged": "^15.2.10",
|
|
27
23
|
"pinst": "^3.0.0",
|
|
28
|
-
"prettier": "^3.
|
|
24
|
+
"prettier": "^3.4.1",
|
|
25
|
+
"send": "^1.1.0",
|
|
29
26
|
"tap": "^21.0.1"
|
|
30
27
|
},
|
|
31
28
|
"scripts": {
|
|
@@ -44,27 +41,5 @@
|
|
|
44
41
|
"printWidth": 100,
|
|
45
42
|
"semi": false,
|
|
46
43
|
"singleQuote": true
|
|
47
|
-
},
|
|
48
|
-
"eslintConfig": {
|
|
49
|
-
"parserOptions": {
|
|
50
|
-
"ecmaFeatures": {
|
|
51
|
-
"ecmaVersion": 2020
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"extends": [
|
|
55
|
-
"standard",
|
|
56
|
-
"prettier",
|
|
57
|
-
"prettier/prettier"
|
|
58
|
-
],
|
|
59
|
-
"rules": {
|
|
60
|
-
"quotes": [
|
|
61
|
-
"error",
|
|
62
|
-
"single",
|
|
63
|
-
{
|
|
64
|
-
"avoidEscape": true,
|
|
65
|
-
"allowTemplateLiterals": true
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
44
|
}
|
|
70
45
|
}
|