Skip to content

having an expired scratch org as the default target-org causes the CLI to hang trying to connect to it #3015

@cristiand391

Description

@cristiand391

If I create a scratch org, set it as the default with sf config set target-org <org-username> --global then left it expire, sf still tries to connect to it and causes a ~10s delay on all commands executions (it tries to conect to the instance URL, which isn't valid at that point.

Expected result

if the target-org expired then it should be ignored

Actual result

expired target-org causes a ~10s delay on all commands (even if it's not using --target-org like sf plugins).

Additional information

Internal:
here's a video of the bug running JSFORCE_LOG_LEVEL=DEBUG sf config list --dev-debug, see how it hangs on retrying the request:
https://salesforce-internal.slack.com/archives/G02K6C90RBJ/p1725468814588979

...
DEBUG   [fetch]  retrying for the 1 time
DEBUG   [fetch]  reason: statusCode match
DEBUG   [fetch]  retrying for the 1 time

System Information

CLI:
@salesforce/cli/2.58.7 darwin-x64 node-v20.10.0

Plugin Version:
@cristiand391/sf-plugin-fzf-cmp 0.2.0 (user)
@oclif/plugin-autocomplete 3.2.2 (core)
@oclif/plugin-commands 4.0.13 (core)
@oclif/plugin-help 6.2.10 (core)
@oclif/plugin-not-found 3.2.18 (core)
@oclif/plugin-plugins 5.4.6 (core)
@oclif/plugin-search 1.2.7 (core)
@oclif/plugin-update 4.5.5 (core)
@oclif/plugin-version 2.2.11 (core)
@oclif/plugin-warn-if-update-available 3.1.13 (core)
@oclif/plugin-which 3.2.12 (core)
@salesforce/cli 2.58.7 (core)
apex 3.4.8 (core)
api 1.2.1 (core)
auth 3.6.54 (core)
data 3.6.5 (core)
deploy-retrieve 3.12.3 (core)
info 3.4.3 (core)
limits 3.3.29 (core)
marketplace 1.2.25 (core)
org 4.5.7 (core)
packaging 2.8.2 (core)
schema 3.3.26 (core)
settings 2.3.16 (core)
sobject 1.4.33 (core)
source 3.5.18 (core)
telemetry 3.6.10 (core)
templates 56.3.17 (core)
trust 3.7.27 (core)
user 3.5.29 (core)
SF ENV. VARS.
SF_DISABLE_TELEMETRY,true
SF_AUTOUPDATE_DISABLE,true
SF_DISABLE_AUTOUPDATE,true
SF_UPDATE_INSTRUCTIONS,Use "npm update --global @salesforce/cli" to update npm-based installations.
Windows: false
Shell: zsh
Channel: stable

Diagnostics

✅ pass - salesforcedx plugin isn’t installed
✅ pass - you don't have any linked plugins
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.yarnpkg.com
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org/
✅ pass - using latest or latest-rc CLI version
❌ warn - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches apiVersion
✅ pass - can access: https://test.salesforce.com
✅ pass - can access: https://appexchange.salesforce.com/services/data
✅ pass - can access: https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-win32-x64-buildmanifest
✅ pass - [@salesforce/plugin-auth] CLI supports v2 crypto

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bugdoctorIssue was created using the 'doctor' commandinvestigatingWe're actively investigating this issuevalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions