@nxtedition/nxt-undici 2.1.0 → 2.2.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/index.js
CHANGED
|
@@ -106,8 +106,8 @@ export async function request(url, opts) {
|
|
|
106
106
|
dispatch = interceptors.requestId(dispatch)
|
|
107
107
|
dispatch = interceptors.responseRetry(dispatch)
|
|
108
108
|
dispatch = interceptors.responseVerify(dispatch)
|
|
109
|
-
dispatch = interceptors.cache(dispatch)
|
|
110
109
|
dispatch = interceptors.redirect(dispatch)
|
|
110
|
+
dispatch = interceptors.cache(dispatch)
|
|
111
111
|
dispatch = interceptors.proxy(dispatch)
|
|
112
112
|
dispatcherCache.set(dispatcher, dispatch)
|
|
113
113
|
}
|
package/lib/interceptor/cache.js
CHANGED
|
@@ -107,7 +107,7 @@ class CacheStore {
|
|
|
107
107
|
|
|
108
108
|
function makeKey(opts) {
|
|
109
109
|
// NOTE: Ignores headers...
|
|
110
|
-
return `${opts.method}:${opts.path}`
|
|
110
|
+
return `${opts.origin}:${opts.method}:${opts.path}`
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const DEFAULT_CACHE_STORE = new CacheStore({ maxSize: 128 * 1024, maxEntrySize: 1024 })
|
|
@@ -153,7 +153,7 @@ class Handler extends DecoratorHandler {
|
|
|
153
153
|
this.#error = err
|
|
154
154
|
|
|
155
155
|
retryPromise
|
|
156
|
-
.then(() => {
|
|
156
|
+
.then((opts) => {
|
|
157
157
|
if (this.#aborted) {
|
|
158
158
|
this.#onError(this.#reason)
|
|
159
159
|
} else if (isDisturbed(this.#opts.body)) {
|
|
@@ -167,8 +167,10 @@ class Handler extends DecoratorHandler {
|
|
|
167
167
|
|
|
168
168
|
this.#opts = {
|
|
169
169
|
...this.#opts,
|
|
170
|
+
...opts,
|
|
170
171
|
headers: {
|
|
171
172
|
...this.#opts.headers,
|
|
173
|
+
...opts?.headers,
|
|
172
174
|
'if-match': this.#etag,
|
|
173
175
|
range: `bytes=${this.#pos}-${this.#end ?? ''}`,
|
|
174
176
|
},
|
|
@@ -204,25 +206,3 @@ export default (dispatch) => (opts, handler) => {
|
|
|
204
206
|
? dispatch(opts, new Handler(opts, { handler, dispatch }))
|
|
205
207
|
: dispatch(opts, handler)
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
export function isConnectionError(err) {
|
|
209
|
-
// AWS compat.
|
|
210
|
-
const statusCode = err?.statusCode ?? err?.$metadata?.httpStatusCode
|
|
211
|
-
return err
|
|
212
|
-
? err.code === 'ECONNRESET' ||
|
|
213
|
-
err.code === 'ECONNREFUSED' ||
|
|
214
|
-
err.code === 'ENOTFOUND' ||
|
|
215
|
-
err.code === 'ENETDOWN' ||
|
|
216
|
-
err.code === 'ENETUNREACH' ||
|
|
217
|
-
err.code === 'EHOSTDOWN' ||
|
|
218
|
-
err.code === 'EHOSTUNREACH' ||
|
|
219
|
-
err.code === 'EPIPE' ||
|
|
220
|
-
err.code === 'ETIMEDOUT' ||
|
|
221
|
-
err.message === 'other side closed' ||
|
|
222
|
-
statusCode === 420 ||
|
|
223
|
-
statusCode === 429 ||
|
|
224
|
-
statusCode === 502 ||
|
|
225
|
-
statusCode === 503 ||
|
|
226
|
-
statusCode === 504
|
|
227
|
-
: false
|
|
228
|
-
}
|