Skip to content

Node.js 24.17.0: jsforce request promise can hang with keep-alive transport #1806

Closed

Description

@kirill-meleshko

jsforce requests can hang indefinitely on Node.js 24.17.0.

The first visible failure in our app was:

await conn.authorize({
  grant_type: 'client_credentials',
});

After isolating the issue, OAuth auth and a normal REST query both work when jsforce sends connection: close.

The same code works on Node.js 24.16.0.

Environment

  • jsforce versions inspected/tested:
    • 3.6.6
    • 3.7.0
    • 3.9.1
    • 3.10.16
  • node-fetch: 2.7.0
  • Node.js:
    • fails: 24.17.0
    • works: 24.16.0
  • Platform:
    • amd64
    • arm64

Reproduction

import jsforce from 'jsforce';

const conn = new jsforce.Connection();

conn.oauth2 = new jsforce.OAuth2({
  clientId: process.env.SALESFORCE_CLIENT_ID,
  clientSecret: process.env.SALESFORCE_CLIENT_SECRET,
  loginUrl: 'https://<my-domain>.develop.my.salesforce.com',
});

await conn.authorize({
  grant_type: 'client_credentials',
});

const result = await conn.query(
  'SELECT Id, CaseNumber, Status, Subject, LastModifiedDate FROM Case LIMIT 1',
);

console.log(result.records[0]);

Observed Behavior

On Node.js 24.17.0, the jsforce request promise can remain unsettled.

In our validation:

  • unpatched jsforce on Node.js 24.17.0 left conn.authorize({ grant_type: 'client_credentials' }) unsettled.
  • adding only content-length to the OAuth token POST did not fix the issue.
  • adding connection: close fixed OAuth auth.
  • adding connection: close in the shared jsforce request transport fixed both OAuth auth and a normal Case query.

Expected Behavior

jsforce requests should either complete successfully or fail with a bounded request error. They should not hang indefinitely on Node.js 24.17.0.

Suspected Cause

jsforce uses node-fetch@2 for its Node request transport. Node.js 24.17.0 uses keep-alive by default for http.globalAgent / https.globalAgent and includes HTTP/TLS security changes, including an http.Agent idle socket data guard and an llhttp update.

This appears to expose an incompatibility between jsforce's current request transport and Node.js 24.17.0 connection reuse behavior.

Diagnostic Workaround

In lib/request.js, setting connection: close for Node requests avoids the hang:

const headers = {
  ...(rrequest.headers ?? {}),
};

if (
  !('window' in globalThis) &&
  !('self' in globalThis) &&
  !Object.keys(headers).some((headerName) => headerName.toLowerCase() === 'connection')
) {
  headers.connection = 'close';
}

const fetchOpts = {
  ...rrequest,
  headers,
  ...(input && /^(post|put|patch)$/i.test(request.method)
    ? { body: input }
    : {}),
  redirect: 'manual',
  signal: controller.signal,
  agent,
};

Local validation showed that content-length alone does not fix the issue. connection: close is the only local workaround we found that avoids the hang, but it is not intended as the long-term jsforce fix.

Validation Result

With connection: close applied in the shared request transport, Node.js 24.17.0 successfully completed:

  • OAuth client_credentials auth
  • SELECT Id, CaseNumber, Status, Subject, LastModifiedDate FROM Case LIMIT 1

The query returned one Case record successfully.

Related Node.js Changes

Node.js 24.17.0 release:
https://nodejs.org/en/blog/release/v24.17.0

Relevant commits:

Activity

  1. changed the title [-]jsforce requests hang on Node.js 24.17.0 unless connection reuse is disabled[/-] [+]Node.js 24.17.0: jsforce request promise can hang with keep-alive transport[/+] on Jun 18, 2026
  2. kirill-meleshko commented on Jun 18, 2026

    @kirill-meleshko
    Author

    Additional clarification: Connection: close should be treated as a diagnostic workaround, not as the proposed jsforce fix.

    jsforce intentionally uses streaming request/response handling and persistent connections, and we do not think the long-term fix should be to disable keep-alive globally.

    The important observation is:

    • jsforce requests hang on Node.js 24.17.0 with the normal transport.
    • The same code works on Node.js 24.16.0.
    • Adding Connection: close makes the request settle on Node.js 24.17.0.

    That suggests the issue is likely in the persistent connection / socket reuse path exposed by Node.js 24.17.0, not in Salesforce OAuth semantics specifically.

    So the desired outcome is to preserve jsforce's existing streaming + keep-alive behavior if possible, while identifying why the promise remains unsettled on Node.js 24.17.0.

    The Connection: close patch is useful only because it narrows the failure boundary to keep-alive / reusable socket handling.

  3. kirill-meleshko commented on Jun 18, 2026

    @kirill-meleshko
    Author
  4. sjgutta commented on Jun 19, 2026

    @sjgutta

    Ran into the same issue today, it was very difficult to debug since requests silently hang despite the request succeeding on the Salesforce side. Confirmed that the only way for us to get back to a working version was to downgrade our docker image back to a node version before these upgrades.

  5. Will-Bill commented on Jun 19, 2026

    @Will-Bill

    Well this had me stumped for 4 hours. Targeting dockerfile back to 24.16.0 fixes it for me. This issue is also on node 22. I am sure its on other node point releases too.

  6. rtraficante commented on Jun 19, 2026

    @rtraficante

    Having the same issue. Authorization is hanging and failing. Haven't tested on any other node versions but direct calls to the salesforce authorization endpoint works just fine.

  7. morganwynne commented on Jun 19, 2026

    @morganwynne

    I ran into the same issue with node 22 and narrowed it down to the new 22.23.0 security release from yesterday.

  8. Muzammillcoste commented on Jun 22, 2026

    @Muzammillcoste

    I faced the same issue, and it took 3 hours of debugging to find this fix.

  9. lundstromdavid commented on Jun 22, 2026

    @lundstromdavid

    Same issue here, temporarily solved it by reverting to a compatible Node version. Skill issue that I didn't use a fixed Node version to be fair, but would love a fix for this so that I can keep Node updated!

  10. GBvanDam commented on Jun 22, 2026

    @GBvanDam
  11. jfeingold35 commented on Jun 22, 2026

    @jfeingold35
    Collaborator

    Hey everyone. We're aware of this issue and we're actively working to fix it. We'll provide more information as and when it becomes available. In the meantime, thank you for your patience.

  12. Bartheleway commented on Jun 26, 2026

    @Bartheleway

    Issue is fixed if you upgrade to v24.18 (nodejs/node#63989). I also created an issue for v26.3.1 (nodejs/node#64142) as they didn't fix it yet.

  13. nbolton commented on Jul 20, 2026

    @nbolton

    Thanks for fixing this, working great!

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