From b0dc7b3b14520ce1f66c2b9d6a0f5aae4028985b Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Mon, 14 Aug 2023 20:53:01 -0400 Subject: [PATCH] chore(internal): fix error happening in CloudFlare pages (#116) --- src/core.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index 480b2c50..92bf81de 100644 --- a/src/core.ts +++ b/src/core.ts @@ -254,7 +254,10 @@ export abstract class APIClient { const timeout = options.timeout ?? this.timeout; const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url); const minAgentTimeout = timeout + 1000; - if ((httpAgent as any)?.options && minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)) { + if ( + typeof (httpAgent as any)?.options?.timeout === 'number' && + minAgentTimeout > ((httpAgent as any).options.timeout ?? 0) + ) { // Allow any given request to bump our agent active socket timeout. // This may seem strange, but leaking active sockets should be rare and not particularly problematic, // and without mutating agent we would need to create more of them.