@nxtedition/nxt-undici 3.2.0 → 3.2.2

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
@@ -18,7 +18,7 @@ export const interceptors = {
18
18
  }
19
19
 
20
20
  export { parseHeaders } from './utils.js'
21
- export { Client, Pool, Agent } from '@nxtedition/undici'
21
+ export { Client, Pool, Agent, getGlobalDispatcher, setGlobalDispatcher } from '@nxtedition/undici'
22
22
 
23
23
  export async function request(url, opts) {
24
24
  // TODO (fix): More argument validation...
@@ -96,5 +96,7 @@ export async function request(url, opts) {
96
96
  error: opts.error ?? true,
97
97
  verify: opts.verify ?? true,
98
98
  logger: opts.logger ?? null,
99
+ lookup: opts.lookup ?? null,
100
+ dns: opts.dns ?? null,
99
101
  })
100
102
  }
@@ -6,15 +6,15 @@ let DEFAULT_DNS
6
6
 
7
7
  class Handler extends DecoratorHandler {
8
8
  #handler
9
- #opts
10
- #hostname
9
+ #store
10
+ #key
11
11
 
12
- constructor(opts, hostname, { handler }) {
12
+ constructor({ store, key }, { handler }) {
13
13
  super(handler)
14
14
 
15
15
  this.#handler = handler
16
- this.#opts = opts
17
- this.#hostname = hostname
16
+ this.#store = store
17
+ this.#key = key
18
18
  }
19
19
 
20
20
  onError(err) {
@@ -31,7 +31,7 @@ class Handler extends DecoratorHandler {
31
31
  'EPIPE',
32
32
  ].includes(err.code)
33
33
  ) {
34
- this.#opts.dns.clear(this.#hostname)
34
+ this.#store.clear(this.#key)
35
35
  }
36
36
 
37
37
  return this.#handler.onError(err)
@@ -59,7 +59,10 @@ export default (opts) => (dispatch) => (opts, handler) => {
59
59
  } else {
60
60
  const url = new URL(opts.origin)
61
61
  url.hostname = entries[Math.floor(entries.length * Math.random())].address
62
- dispatch({ ...opts, origin: url.origin }, new Handler(opts, hostname, { handler }))
62
+ dispatch(
63
+ { ...opts, origin: url.origin },
64
+ new Handler({ store: dns, key: hostname }, { handler }),
65
+ )
63
66
  }
64
67
  }
65
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",