@nxtedition/nxt-undici 3.3.2 → 3.3.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.
@@ -193,7 +193,9 @@ export default (opts) => (dispatch) => (opts, handler) => {
193
193
  } catch (err) {
194
194
  handler.onError(err)
195
195
  }
196
+
197
+ return true
196
198
  } else {
197
- dispatch(opts, new CacheHandler({ handler, store, key: makeKey(opts) }))
199
+ return dispatch(opts, new CacheHandler({ handler, store, key: makeKey(opts) }))
198
200
  }
199
201
  }
@@ -60,35 +60,37 @@ export default (interceptorOpts) => (dispatch) => (opts, handler) => {
60
60
  const { hostname } = new URL(opts.origin)
61
61
 
62
62
  if (net.isIP(hostname)) {
63
- dispatch(opts, handler)
64
- } else {
65
- const callback = (err, val) => {
66
- if (err) {
67
- handler.onConnect(() => {})
68
- handler.onError(err)
69
- } else {
70
- const url = new URL(opts.origin)
71
- url.hostname = Array.isArray(val)
72
- ? val[Math.floor(val.length * Math.random())].address
73
- : val?.address ?? val
74
- dispatch(
75
- { ...opts, origin: url.origin },
76
- resolver.clear ? new Handler({ resolver, key: hostname }, { handler }) : handler,
77
- )
78
- }
79
- }
63
+ return dispatch(opts, handler)
64
+ }
80
65
 
81
- try {
82
- const thenable = resolver.lookup(hostname, { family, hints, order, all }, callback)
83
- if (typeof thenable?.then === 'function') {
84
- thenable.then(
85
- (val) => callback(null, val),
86
- (err) => callback(err),
87
- )
88
- }
89
- } catch (err) {
66
+ const callback = (err, val) => {
67
+ if (err) {
90
68
  handler.onConnect(() => {})
91
69
  handler.onError(err)
70
+ } else {
71
+ const url = new URL(opts.origin)
72
+ url.hostname = Array.isArray(val)
73
+ ? val[Math.floor(val.length * Math.random())].address
74
+ : val?.address ?? val
75
+ dispatch(
76
+ { ...opts, origin: url.origin },
77
+ resolver.clear ? new Handler({ resolver, key: hostname }, { handler }) : handler,
78
+ )
92
79
  }
93
80
  }
81
+
82
+ try {
83
+ const thenable = resolver.lookup(hostname, { family, hints, order, all }, callback)
84
+ if (typeof thenable?.then === 'function') {
85
+ thenable.then(
86
+ (val) => callback(null, val),
87
+ (err) => callback(err),
88
+ )
89
+ }
90
+ } catch (err) {
91
+ handler.onConnect(() => {})
92
+ handler.onError(err)
93
+ }
94
+
95
+ return true
94
96
  }
@@ -25,4 +25,6 @@ export default (opts) => (dispatch) => (opts, handler) => {
25
25
  } catch (err) {
26
26
  callback(err)
27
27
  }
28
+
29
+ return true
28
30
  }
@@ -16,11 +16,13 @@ export default (opts) => (dispatch) => (opts, handler) => {
16
16
  handler.onError(err)
17
17
  },
18
18
  )
19
+ return true
19
20
  } else {
20
- dispatch({ ...opts, body }, handler)
21
+ return dispatch({ ...opts, body }, handler)
21
22
  }
22
23
  } catch (err) {
23
24
  handler.onConnect(() => {})
24
25
  handler.onError(err)
26
+ return true
25
27
  }
26
28
  }
package/lib/utils.js CHANGED
@@ -3,6 +3,8 @@ import cacheControlParser from 'cache-control-parser'
3
3
  import stream from 'node:stream'
4
4
  import { util } from '@nxtedition/undici'
5
5
 
6
+ const noop = () => {}
7
+
6
8
  export function parseCacheControl(str) {
7
9
  return str ? cacheControlParser.parse(str) : null
8
10
  }
@@ -267,7 +269,7 @@ export class DecoratorHandler {
267
269
  onError(...args) {
268
270
  if (!this.#onConnectCalled) {
269
271
  this.#onConnectCalled = true
270
- this.#handler.onConnect?.(...args)
272
+ this.#handler.onConnect?.(noop)
271
273
  }
272
274
  return this.#handler.onError?.(...args)
273
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",