diff options
-rw-r--r-- | packages/taler-util/src/http-impl.node.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/taler-util/src/http-impl.node.ts b/packages/taler-util/src/http-impl.node.ts index 4df1feaf0..639043201 100644 --- a/packages/taler-util/src/http-impl.node.ts +++ b/packages/taler-util/src/http-impl.node.ts @@ -21,6 +21,7 @@ */ import * as http from "node:http"; import * as https from "node:https"; +import * as net from "node:net"; import { RequestOptions } from "node:http"; import { TalerError } from "./errors.js"; import { encodeBody, getDefaultHeaders, HttpLibArgs } from "./http-common.js"; @@ -39,6 +40,19 @@ import { URL, } from "./index.js"; +// Work around a node v20.0.0, v20.1.0, and v20.2.0 bug. The issue was fixed +// in v20.3.0. +// https://github.com/nodejs/node/issues/47822#issuecomment-1564708870 +// Safe to remove once support for Node v20 is dropped. +if ( + // check for `node` in case we want to use this in "exotic" JS envs + process.versions.node && + process.versions.node.match(/20\.[0-2]\.0/) +) { + //@ts-ignore + net.setDefaultAutoSelectFamily(false); +} + const logger = new Logger("http-impl.node.ts"); const textDecoder = new TextDecoder(); @@ -126,6 +140,7 @@ export class HttpLibImpl implements HttpRequestLibrary { method: method, path, headers: requestHeadersMap, + timeout: timeoutMs, }; const chunks: Uint8Array[] = []; |