Skip to content

CLI doesn't work with node v24.17.0 or later. #3586

Closed
salesforcecli/sf-plugins-core
#723

Description

@PankajamM

Command failed: sf org login sfdx-url --sfdx-url-file files/authFile.json --alias MyDefaultOrg --json

Error received :
Warning: Detected unsettled top-level await at file://node_modules/@salesforce/cli/bin/run.js:15 await cli.run();

I am using Salesforce CLI version 2.139.6 installed via npm (@salesforce/cli) and running the command in CI with:

Node.js: v24 (and also tested with v22)
OS: GitHub Actions Ubuntu runner

The issue is reproducible consistently with:

sf org login sfdx-url --sfdx-url-file --alias --json

Error observed:

Warning: Detected unsettled top-level await at @salesforce/cli/bin/run.js

The same setup works correctly with Node.js v20, but fails on Node 22 and 24 with the above runtime warning and CLI failure during bootstrap.

Please confirm if Salesforce CLI 2.139.x supports Node 24 in npm-based installations, or if there is a known compatibility issue with the CLI bootstrap process under Node 24.

Activity

  1. added
    investigating
    on Jun 20, 2026
  2. github-actions commented on Jun 20, 2026

    @github-actions

    Hello @PankajamM 👋 It looks like you didn't include the full Salesforce CLI version information in your issue.
    Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

    A few more things to check:

    • Make sure you've provided detailed steps to reproduce your issue.
      • A repository that clearly demonstrates the bug is ideal.
    • Make sure you've installed the latest version of Salesforce CLI. (docs)
      • Better yet, try the rc or nightly versions. (docs)
    • Try running the doctor command to diagnose common issues.
    • Search GitHub for existing related issues.

    Thank you!

  3. added
    more information required
    and removed
    investigating
    on Jun 20, 2026
  4. github-actions commented on Jun 20, 2026

    @github-actions

    Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

  5. PankajamM commented on Jun 20, 2026

    @PankajamM
    Author

    Thanks for the response.

    I am using Salesforce CLI version 2.139.6 installed via npm (@salesforce/cli) and running the command in CI with:

    Node.js: v24 (and also tested with v22)
    OS: GitHub Actions Ubuntu runner

    The issue is reproducible consistently with:

    sf org login sfdx-url --sfdx-url-file --alias --json

    Error observed:

    Warning: Detected unsettled top-level await at @salesforce/cli/bin/run.js

    The same setup works correctly with Node.js v20, but fails on Node 22 and 24 with the above runtime warning and CLI failure during bootstrap.

    Please confirm if Salesforce CLI 2.139.x supports Node 24 in npm-based installations, or if there is a known compatibility issue with the CLI bootstrap process under Node 24.

  6. sauloefo commented on Jun 21, 2026

    @sauloefo

    Hi folks, I hit this same issue and asked Claude to help me with the root-cause analysis. I hope it helps:


    Root cause: the bundled [email protected] (via @jsforce/jsforce-node) fails to
    decompress gzip responses on Node ≥22, and jsforce-node swallows the resulting stream
    error, so the request promise never settles — which is what surfaces as the "unsettled
    top-level await" / exit 13.

    Repro matrix (CLI 2.139.6, @jsforce/jsforce-node 3.10.15 → node-fetch 2.7.0, linux):
    Node 18.20.8 ✅ · 20.20.2 ✅ · 22.23.0 ❌ · 24.17.0 ❌

    It is NOT specific to org login sfdx-url — it hits any command that makes an API call
    (login, org display, deploy, query, bulk; org list with no saved org only "works"
    because it makes no network call).

    Mechanism (traced with async_hooks + node-fetch in isolation):

    1. The request itself is fine — the OAuth/token call returns HTTP 200. The failure is in
      reading the response body.
    2. node-fetch sends Accept-Encoding: gzip; Salesforce responds Content-Encoding: gzip.
      On Node ≥22, node-fetch 2.7.0's gunzip stream throws FetchError: ... Premature close.
      Node's built-in fetch (undici) and raw https read the same response fine, so this is a
      node-fetch v2 incompatibility with Node ≥22's stricter stream-end handling, not a Node
      core bug.
    3. In @jsforce/jsforce-node/lib/request.js (startFetchRequest) the body is consumed via
      res.body.pipe(output) (→ request-helper.js → util/stream.js readAll). .pipe()
      does not forward the source's error, and there's no error handler on res.body, so
      the "Premature close" is swallowed. readAll resolves on the downstream 'finish',
      which never fires; the socket has already closed so no libuv handle remains, the loop
      drains, and await cli.run() is left unsettled → exit 13.

    Minimal proof (Node 24):

    const fetch = require('node-fetch'); // the 2.7.0 bundled by the CLI
    const res = await fetch(url, { method:'POST', body, headers });   // 200, content-encoding: gzip
    await res.text();                    // ❌ "Premature close" on Node 22/24, ✅ on 18/20
    // res with { compress:false }       // ✅ on all versions (no gzip requested)
  7. trysmr commented on Jun 21, 2026

    @trysmr

    Hi,

    I’m seeing what looks like the same issue, but with a narrower reproduction around the June 18, 2026 Node.js security releases.

    I tested the same Salesforce CLI version with the immediately preceding Node.js versions and the June 18 security release versions.

    Environment:

    • @salesforce/cli 2.139.6
    • darwin-arm64
    • npm-installed CLI under mise-managed Node.js

    Command:

    sf doctor
    

    Working:

    • Node 22.22.3
    • Node 24.16.0
    • Node 26.3.0

    Failing:

    • Node 22.23.0
    • Node 24.17.0
    • Node 26.3.1

    Observed failure:

    The command does not complete. It stops after:

    fail - [@salesforce/plugin-auth] CLI supports v2 crypto
    

    Then Node.js prints:

    Warning: Detected unsettled top-level await at .../@salesforce/cli/bin/run.js:15
    await cli.run();
    

    In the working versions, sf doctor completes and writes the diagnosis JSON file.

    Since all failing versions are Node.js June 18, 2026 security releases, while the immediately preceding versions work, this appears to be triggered by the June 18 Node.js security updates rather than by a specific Node.js major version.

    Hope this helps narrow it down.

  8. nwcm commented on Jun 22, 2026

    @nwcm

    Also seeing this issue. With either

    @salesforce/cli/2.130.9 win32-x64 node-v22.23.0
    @salesforce/cli/2.138.6 win32-x64 node-v24.17.0

  9. rsstan commented on Jun 22, 2026

    @rsstan

    I encountered the same issue with both of the following versions:

    @salesforce/cli/2.113.6 linux-x64 node-v24.17.0
    @salesforce/cli/2.138.6 linux-x64 node-v24.17.0
    

    The issue disappeared after I downgraded Node.js to v24.12.0.

  10. SalikLP commented on Jun 22, 2026

    @SalikLP

    I have the same issue. Even running sf org list or sf org display gives the error:

    Warning: Detected unsettled top-level await at file:///C:/tools/nvm/v24.17.0/node_modules/@salesforce/cli/bin/run.js:15
    await cli.run();
    
  11. added theissue type on Jun 22, 2026
  12. added
    bug
    and removed
    more information required
    on Jun 22, 2026
  13. git2gus commented on Jun 22, 2026

    @git2gus

    This issue has been linked to a new work item: W-23121570

  14. 14 remaining items

  15. jfeingold35 commented on Jun 26, 2026

    @jfeingold35

    @branderson-js , neither, actually.
    The CLI depends on jsforce, a third-party library that we play a very active role in maintaining. The latest minor versions of Node broke node-fetch@v2, which is a dependency of jsforce, and therefore broke the CLI.
    The fix was to migrate away from node-fetch and to the native fetch API introduced to Node in v18.

  16. branderson-js commented on Jun 26, 2026

    @branderson-js

    Understood. we are on node v22.9.0 and have not seen any issues. I am just trying to determine if I hold off updating our sf cli version or change our node version

  17. br0bison commented on Jun 26, 2026

    @br0bison

    Hey everyone. It's our belief that this issue should be resolved in the latest nightly CLI build. If you run npm install --global @salesforce/cli@nightly, and then run your commands, do you still experience the error?

    @nightly installed v2.142.1 and I do not receive an authentication failure or --target-org requirement

    Can confirm using @nightly resolved our issues.

  18. jfeingold35 commented on Jun 26, 2026

    @jfeingold35

    @branderson-js , the issue is reproducible on any version of the CLI (except for the new nightly), as long as your Node version is one of the ones released last Friday (v22.23.0, v24.17.0, or v26.3.1). According to @Bartheleway , it's also been fixed in the version of v24 released today, which is great news.

  19. jfeingold35 commented on Jun 26, 2026

    @jfeingold35

    @br0bison , excellent news! That being the case, I'm going to close this Issue.
    If anyone is still experiencing problems, please add additional comments here and we can re-open the issue if needed.

  20. Bartheleway commented on Jun 26, 2026

    @Bartheleway

    @branderson-js , neither, actually. The CLI depends on jsforce, a third-party library that we play a very active role in maintaining. The latest minor versions of Node broke node-fetch@v2, which is a dependency of jsforce, and therefore broke the CLI. The fix was to migrate away from node-fetch and to the native fetch API introduced to Node in v18.

    Yes correct, a minor security fix in NodeJs created an issue in node-fetch which is used by jsforce itself used by sf cli.
    Several ways for fixing were possible:

    • Wait for NodeJs to fix the fix: They did fix it in 22.23.1, 24.18.0 and 26.4.0.
    • Wait for a fix in node-fetch: Not gonna happen as project seems dead
    • Migrate away from node-fetch in jsforce and update jsforce in @salesforce/cli to avoid future issues: Done in nightly it seems.

    We should be safe now.

  21. branderson-js commented on Jun 29, 2026

    @branderson-js

    Would the change of which fetch the sf cli is using had an effect on proxy usage?

  22. codefriar commented on Jun 29, 2026

    @codefriar

    @Bartheleway - I believe you might want to re-open this.

    using @nightly i can 100% login via jwt - however, the JIT install of signups fails. So when I move on from authentication to running sf org snapshot list --target-dev-hub devHub --json it dies with the exact same error:

    Querying DevHub for latest active baseline snapshot...
    Warning: sf stderr output: @salesforce/cli: Installing plugin [email protected]... installed v2.6.73
    Warning: Detected unsettled top-level await at file:///opt/hostedtoolcache/node/24.17.0/x64/lib/node_modules/@salesforce/cli/bin/run.js:15
    await cli.run();
    ^
    Error: Failed to query snapshots (exit 13): 
    Error: Process completed with exit code 1.
    
  23. unpinned this issue on Jul 1, 2026
  24. pinned this issue on Jul 2, 2026
  25. ZergyPoo commented on Jul 14, 2026

    @ZergyPoo

    This error is still stopping me from using the CLI this morning. Can we re-open the issue?

  26. ZergyPoo commented on Jul 14, 2026

    @ZergyPoo

    I can't even install the nightly version, I encounter the same await error when attempting to run sf upgrade nightly

  27. unpinned this issue on Jul 14, 2026
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

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions