Skip to content

fix(request): support https-proxy-agent v7 named export (retain v5 compat) - #1759

Open
ckersey2 wants to merge 2 commits into
jsforce:mainfrom
ckersey2:fix/https-proxy-agent-v7
Open

ckersey2 wants to merge 2 commits into
jsforce:mainfrom
ckersey2:fix/https-proxy-agent-v7

Conversation

@ckersey2

@ckersey2 ckersey2 commented Sep 8, 2025

Copy link
Copy Markdown

Summary

JSforce throws at runtime when the dependency tree resolves https-proxy-agent@7:

TypeError: (0, https_proxy_agent_1.default) is not a function

v7 switched to a named class export (HttpsProxyAgent), while the current code assumes a default export. This PR adds a tiny compatibility shim to support both v5 (default export) and v7 (named export).

Change

// before
import createHttpsProxyAgent from 'https-proxy-agent';
const agent = httpProxy ? createHttpsProxyAgent(httpProxy) : undefined;

// after (compat for v5 & v7)
import * as HttpsProxyAgentNS from 'https-proxy-agent';
const HttpsProxyAgentCtor: any =
  (HttpsProxyAgentNS as any).HttpsProxyAgent ??
  (HttpsProxyAgentNS as any).default;
const agent = httpProxy ? new HttpsProxyAgentCtor(httpProxy) : undefined;

Why

  • https-proxy-agent@7 is ESM-only with named exports; the default is undefined.
  • Backwards compatible: still works if a consumer has v5 in the tree.

Environment

  • JSforce: 3.10.5 (issue reproduced on npm release)
  • Patched in: commit 7b74bbf (branch fix/https-proxy-agent-v7)
  • Runtime: Bun v1.2.21 (also tested Node v22 if applicable)
  • Package manager: Bun (bun install)
  • https-proxy-agent: 7.x

Issue
Fixes #1758

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: (0, https_proxy_agent_1.default) is not a function when using jsforce with https-proxy-agent@7+

1 participant