@nxtedition/nxt-undici 6.4.13 → 6.4.15
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 +1 -1
- package/lib/interceptor/lookup.js +14 -1
- package/lib/request.js +1 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -142,7 +142,7 @@ function wrapDispatch(dispatcher) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export function dispatch(dispatcher, opts, handler) {
|
|
145
|
-
return wrapDispatch(dispatcher)(opts, handler)
|
|
145
|
+
return wrapDispatch(dispatcher)(opts, handler)?.catch((err) => handler.onError(err))
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
export async function request(url, opts) {
|
|
@@ -5,7 +5,20 @@ export default () => (dispatch) => async (opts, handler) => {
|
|
|
5
5
|
return dispatch(opts, handler)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const origin = await
|
|
8
|
+
const origin = await new Promise((resolve, reject) => {
|
|
9
|
+
const thenable = lookup(opts.origin, { signal: opts.signal ?? undefined }, (err, val) => {
|
|
10
|
+
if (err) {
|
|
11
|
+
reject(err)
|
|
12
|
+
} else {
|
|
13
|
+
resolve(val)
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if (thenable != null) {
|
|
18
|
+
Promise.resolve(thenable).then(resolve, reject)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
9
22
|
if (!origin) {
|
|
10
23
|
throw new Error('invalid origin: ' + origin)
|
|
11
24
|
}
|
package/lib/request.js
CHANGED
|
@@ -190,7 +190,5 @@ export function request(dispatch, url, opts) {
|
|
|
190
190
|
body: isStream(opts?.body) && opts.body.closed ? null : opts?.body,
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
return new Promise((resolve,
|
|
194
|
-
dispatch(opts, new RequestHandler(opts, resolve))?.catch(reject),
|
|
195
|
-
)
|
|
193
|
+
return new Promise((resolve) => dispatch(opts, new RequestHandler(opts, resolve)))
|
|
196
194
|
}
|