Skip to content

Commit

Permalink
Merge branch 'nxtedition:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
IsakT authored Aug 13, 2024
2 parents f4be925 + 866794e commit 35c99c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const interceptors = {
export { parseHeaders } from './utils.js'
export { Client, Pool, Agent, getGlobalDispatcher, setGlobalDispatcher } from 'undici'

function defaultLookup(origin, opts, callback) {
callback(null, Array.isArray(origin) ? origin[Math.floor(Math.random() * origin.length)] : origin)
}

function wrapDispatcher(dispatcher) {
let wrappedDispatcher = dispatcherCache.get(dispatcher)
if (wrappedDispatcher == null) {
Expand Down Expand Up @@ -60,7 +64,7 @@ function wrapDispatcher(dispatcher) {
headersTimeout: opts.headersTimeout,
bodyTimeout: opts.bodyTimeout,
idempotent: opts.idempotent,
retry: opts.retry ?? 8,
retry: opts.retry ?? 4,
proxy: opts.proxy ?? false,
cache: opts.cache ?? false,
upgrade: opts.upgrade ?? false,
Expand All @@ -70,15 +74,7 @@ function wrapDispatcher(dispatcher) {
logger: opts.logger ?? null,
dns: opts.dns ?? true,
connect: opts.connect,
lookup:
opts.lookup ??
((origin, opts, callback) =>
callback(
null,
Array.isArray(origin)
? origin[Math.floor(Math.random() * origin.length)]
: origin,
)),
lookup: opts.lookup ?? defaultLookup,
maxRedirections: 0, // TODO (fix): Ugly hack to disable undici redirections.
},
handler,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nxtedition/nxt-undici",
"version": "4.2.4",
"version": "4.2.5",
"license": "MIT",
"author": "Robert Nagy <robert.nagy@boffins.se>",
"main": "lib/index.js",
Expand Down

0 comments on commit 35c99c2

Please sign in to comment.