cli icon indicating copy to clipboard operation
cli copied to clipboard

Unsettled top-level await in `sf org list`

Open kyle-blair opened this issue 2 months ago • 12 comments

Note Before you submit your issue, make sure that:

  • You're using the latest version of Salesforce CLI.
  • You've searched both open and closed issues for related posts.
  • You've used the doctor command to diagnose common issues.
  • You understand that GitHub Issues don't adhere to any agreement or SLA.
    • If you require immediate assistance, use official channels such as Salesforce Customer Support.

Summary

I just updated to the latest version of sf, and now running the sf org list command gives only the following output (it doesn't list any orgs that I'm connected to).

$ sf org list
Warning: Detected unsettled top-level await at file:///Users/user/.nvm/versions/node/v22.20.0/lib/node_modules/@salesforce/cli/bin/run.js:15
await cli.run();
^



Steps To Reproduce

Steps 2 and 3 are assumed to be necessary, but I can't say for sure. The error appears related to dns in some way, which may mean it only occurs when dns is involved/required.

  1. Install this version @salesforce/cli/2.109.7.
  2. Create a sandbox and authenticate to it using the cli (i.e. sf org login web ...).
  3. Delete the sandbox.
  4. It may be necessary to wait some time for dns records to expire? Could try clearing your system's dns cache to simulate the passage of time.
  5. Run sf org list.

Expected result

Orgs are listed, if any.

Actual result

$ sf org list
Warning: Detected unsettled top-level await at file:///Users/user/.nvm/versions/node/v22.20.0/lib/node_modules/@salesforce/cli/bin/run.js:15
await cli.run();
^



System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.109.7",
  "nodeVersion": "node-v22.20.0",
  "osVersion": "Darwin 24.6.0",
  "rootPath": "/Users/user/.nvm/versions/node/v22.20.0/lib/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.35 (core)",
    "@oclif/plugin-commands 4.1.33 (core)",
    "@oclif/plugin-help 6.2.33 (core)",
    "@oclif/plugin-not-found 3.2.68 (core)",
    "@oclif/plugin-plugins 5.4.48 (core)",
    "@oclif/plugin-search 1.2.32 (core)",
    "@oclif/plugin-update 4.7.8 (core)",
    "@oclif/plugin-version 2.2.33 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.48 (core)",
    "@oclif/plugin-which 3.2.40 (core)",
    "@salesforce/cli 2.109.7 (core)",
    "agent 1.24.13 (core)",
    "apex 3.8.3 (core)",
    "api 1.3.3 (core)",
    "auth 3.9.17 (core)",
    "data 4.0.58 (core)",
    "deploy-retrieve 3.23.3 (core)",
    "info 3.4.88 (core)",
    "limits 3.3.67 (core)",
    "marketplace 1.3.8 (core)",
    "org 5.9.32 (core)",
    "packaging 2.20.5 (core)",
    "schema 3.3.82 (core)",
    "settings 2.4.48 (core)",
    "signups 2.6.28 (user) published 164 days ago (Sat May 17 2025) (latest is 2.6.53)",
    "sobject 1.4.73 (core)",
    "telemetry 3.6.58 (core)",
    "templates 56.3.65 (core)",
    "trust 3.7.113 (core)",
    "user 3.6.38 (core)"
  ]
}

kyle-blair avatar Oct 30 '25 00:10 kyle-blair

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.

github-actions[bot] avatar Oct 30 '25 00:10 github-actions[bot]

I can't repro even with the same node version:

Image

questions:

  1. can you repro using a previous CLI version?
  2. can you repro on a separate machine?

cristiand391 avatar Oct 30 '25 13:10 cristiand391

Interesting, so I did some more digging and I'm ashamed to say I didn't think to try running with --dev-debug. I am behind a corporate proxy server, and with the debug output, I noticed I was getting a lot of HTTP/1.1 502 notresolvable responses from the proxy server. I also noticed the environment variableSF_DISABLE_DNS_CHECK mentioned in the output. I've had that enabled for years (honestly don't remember the reason). So, I tried export SF_DISABLE_DNS_CHECK=false and then the output went back to expected.

A sandbox I have local connections to was deleted, and it shows the status as DomainNotFoundError. It appears that the combination of the proxy and SF_DISABLE_DNS_CHECK=true meant that the promise never resolved.

I would suggest that this still represents a bug, as the main promise behind await cli.run() should always resolve (or reject). Let me know your thoughts!

kyle-blair avatar Oct 30 '25 21:10 kyle-blair

Even more interesting, the documentation on SF_DISABLE_DNS_CHECK specifically says it is useful if you get a DomainNotFound error...

kyle-blair avatar Oct 31 '25 19:10 kyle-blair

thanks for the detailed info!

I'll try to repro this later this week, I'm pretty sure unsettled promises messes up our telemetry reporting so it's hard to know how many people hit this.

cristiand391 avatar Nov 03 '25 17:11 cristiand391

I noticed this error went away for me and realized it may also be dependent on the invalid connection I mentioned. I used to have two connections to the same sandbox (different users), and that sandbox didn't exist anymore. I have since deleted those two connections using sf org logout, and am no longer experiencing the unsettled await error. I am, however, now on version 2.108.6 of the sf cli, so that's potentially another variable to contend with. I will update the steps to reproduce just in case it's relevant.

kyle-blair avatar Nov 05 '25 21:11 kyle-blair

I get this error 100% now on any sf install plugin execution - running node/24.11.1

ficcaglia avatar Nov 20 '25 13:11 ficcaglia

@ficcaglia could you pass --dev-debug to one of the runs that fail? getting the stacktrace of the unsettled promise would help a lot. thanks!

cristiand391 avatar Nov 20 '25 13:11 cristiand391

@cristiand391 Does this help at all

sf plugins install code-analyzer@latest --dev-debug

Warning: Detected unsettled top-level await at file:///home/runner/tmp/bin/run.js:15
[15:00:07.804] DEBUG (sf:oclif:InstallationVerification): verify | Found npmMeta? true
await cli.run();
^
[15:00:07.804] DEBUG (sf:oclif:InstallationVerification): verify | creating a read stream for path - npmMeta.tarballLocalPath: /home/runner/.cache/sf/salesforce-plugin-code-analyzer-5.6.1.tgz
[15:00:07.804] DEBUG (sf:oclif:InstallationVerification): verify | npmMeta.signatureUrl: https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-code-analyzer/5.6.1.sig
[15:00:07.804] DEBUG (sf:oclif:InstallationVerification): verify | npmMeta.publicKeyUrl: https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-code-analyzer/5.6.1.crt
2025-11-20T15:00:08.626Z sf:telemetry Unable to get oclif performance metrics Error: Perf results not available. Did you forget to call await Performance.collect()?
    at get oclifPerf (/home/runner/tmp/node_modules/@oclif/core/lib/performance.js:218:15)
    at process.<anonymous> (file:///home/runner/tmp/node_modules/@salesforce/plugin-telemetry/lib/hooks/telemetryPrerun.js:81:41)
    at Object.onceWrapper (node:events:634:26)
    at process.emit (node:events:531:35)
    at process.processEmit (/home/runner/tmp/node_modules/signal-exit/index.js:191:37)
    at #processEmit (file:///home/runner/tmp/node_modules/@inquirer/confirm/node_modules/signal-exit/dist/mjs/index.js:234:28)
    at #process.emit (file:///home/runner/tmp/node_modules/@inquirer/confirm/node_modules/signal-exit/dist/mjs/index.js:187:37)
    at process.callbackTrampoline (node:internal/async_hooks:130:17)
2025-11-20T15:00:08.630Z sf:telemetry Spawning "/home/runner/tmp/bin/node /home/runner/tmp/node_modules/@salesforce/plugin-telemetry/processes/upload.js /home/runner/.cache/sf /tmp/sf-telemetry/telemetry-d06769fa09c519be63564771bc71c59a8dcac0fc.log"

25h
Error: Process completed with exit code 13.

spw-dhurran avatar Nov 20 '25 15:11 spw-dhurran

@spw-dhurran there's an ongoing issue that's causing those failures, follow this issue for more updates: https://github.com/forcedotcom/cli/issues/3458#issuecomment-3558672282

cristiand391 avatar Nov 20 '25 15:11 cristiand391

@cristiand391 FYI I reverted to 2.108.6 to test and it passes.

spw-dhurran avatar Nov 20 '25 15:11 spw-dhurran

@spw-dhurran folks in the linked issue report is working again, you should be good to go to latest stable.

cristiand391 avatar Nov 20 '25 16:11 cristiand391