Skip to content

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

Open

Description

@ckersey2

Description:

After updating my dependencies, my application started throwing the following error when making requests with JSforce:

TypeError: (0, https_proxy_agent_1.default) is not a function. (In '(0, https_proxy_agent_1.default)(httpProxy)', '(0, https_proxy_agent_1.default)' is undefined)
    at startFetchRequest (/node_modules/jsforce/lib/request.js:53:55)
    at request (/node_modules/jsforce/lib/request.js:206:5)
    ...

Steps to Reproduce:

  1. Install the latest JSforce (e.g. 3.x).
  2. Let it resolve to [email protected] in the dependency tree.
  3. Attempt any operation that requires httpProxy (or leave HTTP_PROXY / HTTPS_PROXY set in the environment).
  4. JSforce crashes with the above error.

Expected Behavior:

JSforce should work with https-proxy-agent@7+ without error, using the new API.

Actual Behavior:

JSforce is calling https_proxy_agent_1.default(httpProxy) which assumes a default-exported function. Since https-proxy-agent@7 now uses a named export (HttpsProxyAgent class), this results in undefined and a runtime TypeError.

Cause:

  • https-proxy-agent@5 had a CommonJS-compatible default export that was callable.
  • https-proxy-agent@7 uses ESM-only named exports:
  • JSforce code in request.js still expects the older default function API.

Workarounds:

  • Pin https-proxy-agent to 5.0.1 using overrides / resolutions.
  • Or unset/remove httpProxy if not needed.

Proposed Fix:

Update JSforce’s import and usage to handle the current API:

- const agent = httpProxy ? https_proxy_agent_1.default(httpProxy) : undefined;
+ const { HttpsProxyAgent } = require("https-proxy-agent");
+ const agent = httpProxy ? new HttpsProxyAgent(httpProxy) : undefined;

(or equivalent ESM import syntax).

Environment:

  • JSforce version: 3.10.5
  • Runtime: Bun v1.2.21
  • Package Manager: Bun
  • https-proxy-agent: 7.0.6

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions