@nxtedition/nxt-undici 4.2.14 → 4.2.16
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 +4 -4
- package/lib/interceptor/response-error.js +14 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -36,9 +36,9 @@ function wrapDispatcher(dispatcher) {
|
|
|
36
36
|
interceptors.requestId(),
|
|
37
37
|
interceptors.responseRetry(),
|
|
38
38
|
interceptors.responseVerify(),
|
|
39
|
-
interceptors.redirect(),
|
|
40
|
-
interceptors.cache(),
|
|
41
39
|
interceptors.proxy(),
|
|
40
|
+
interceptors.cache(),
|
|
41
|
+
interceptors.redirect(),
|
|
42
42
|
(dispatch) => (opts, handler) => {
|
|
43
43
|
const headers = parseHeaders(opts.headers)
|
|
44
44
|
|
|
@@ -59,8 +59,8 @@ function wrapDispatcher(dispatcher) {
|
|
|
59
59
|
query: opts.query,
|
|
60
60
|
headers,
|
|
61
61
|
signal: opts.signal,
|
|
62
|
-
reset: opts.reset ??
|
|
63
|
-
blocking: opts.blocking ??
|
|
62
|
+
reset: opts.reset ?? null,
|
|
63
|
+
blocking: opts.blocking ?? null,
|
|
64
64
|
headersTimeout: opts.headersTimeout,
|
|
65
65
|
bodyTimeout: opts.bodyTimeout,
|
|
66
66
|
idempotent: opts.idempotent,
|
|
@@ -72,18 +72,11 @@ class Handler extends DecoratorHandler {
|
|
|
72
72
|
const stackTraceLimit = Error.stackTraceLimit
|
|
73
73
|
Error.stackTraceLimit = 0
|
|
74
74
|
try {
|
|
75
|
-
err =
|
|
76
|
-
url: new URL(this.#opts.path, this.#opts.origin).href,
|
|
77
|
-
reason: this.#body?.reason,
|
|
78
|
-
code: this.#body?.code,
|
|
79
|
-
error: this.#body?.error,
|
|
80
|
-
headers: this.#headers,
|
|
81
|
-
body: this.#body,
|
|
82
|
-
})
|
|
75
|
+
err = createHttpError(this.#statusCode)
|
|
83
76
|
} finally {
|
|
84
77
|
Error.stackTraceLimit = stackTraceLimit
|
|
85
78
|
}
|
|
86
|
-
this.#handler.onError(err)
|
|
79
|
+
this.#handler.onError(this.#decorateError(err))
|
|
87
80
|
} else {
|
|
88
81
|
this.#handler.onComplete(rawTrailers)
|
|
89
82
|
}
|
|
@@ -93,9 +86,20 @@ class Handler extends DecoratorHandler {
|
|
|
93
86
|
if (this.#errored) {
|
|
94
87
|
// Do nothing...
|
|
95
88
|
} else {
|
|
96
|
-
this.#handler.onError(err)
|
|
89
|
+
this.#handler.onError(this.#decorateError(err))
|
|
97
90
|
}
|
|
98
91
|
}
|
|
92
|
+
|
|
93
|
+
#decorateError(err) {
|
|
94
|
+
Object.assign(err, {
|
|
95
|
+
url: new URL(this.#opts.path, this.#opts.origin).href,
|
|
96
|
+
headers: this.#headers,
|
|
97
|
+
reason: this.#body?.reason,
|
|
98
|
+
code: this.#body?.code,
|
|
99
|
+
error: this.#body?.error,
|
|
100
|
+
body: typeof this.#body !== 'string' || this.#body.length < 1024 ? this.#body : undefined,
|
|
101
|
+
})
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
export default (opts) => (dispatch) => (opts, handler) =>
|