Skip to content

[BUG]: Config and auth changes are silently lost after the computer sleeps #3667

Open

Description

@mihapus

Before You Submit

  • I'm using the latest version of Salesforce CLI
  • I've searched the existing issues
  • I've run sf doctor to diagnose common issues

Related Issue

No response

Command

None. It affects any long-running process that uses @salesforce/core (seen in the VS Code extensions)

Org Type

Not applicable

Did this work before?

Not sure

Last Working Version

No response

Summary

nowBigInt() in @salesforce/core uses performance.timeOrigin + performance.now(). On Linux, performance.now() stops counting while the computer is asleep. So in any process that has lived through a sleep (e.g. the VS Code extension host), "now" falls behind the real time by however long the computer slept.

ConfigFile.write() merges what's in memory with the file on disk and keeps whichever is newer, comparing these timestamps with the file's mtime (real time). The in-memory values always look older, so they're silently thrown away.

Evidence (VS Code extension host, open for 4.5 days on Linux):

  • Date.now(): Oct 16 11:11
  • performance.timeOrigin + performance.now(): Oct 13 15:30 (67.7 h behind)
  • Total time the system was suspended: 67.7 h

Repository to Reproduce

No response

Steps to reproduce

  1. Run:
    node -e 'setInterval(()=>console.log("lag ms:", Date.now()-(performance.timeOrigin+performance.now())), 5000)'
    
  2. Put the computer to sleep for a few minutes, then wake it.
  3. The lag jumps by the sleep time. @salesforce/core uses this value as "now" when saving config/auth files.

Real-world: keep VS Code with the Salesforce extensions open, let the computer sleep, then change the default org or let the access token expire.

Expected Result

Changes made by a long-running process (refreshed access token, new default org) are saved to disk.

Actual Result

The changes are silently dropped:

  • A refreshed access token is never saved, and refreshFn hands back the old expired one. Request → 401 → refresh → old token → 401 → ... forever. In VS Code this caused ~2 logins per second until Salesforce locked the user out with "login rate exceeded" (which also breaks the CLI).
  • Changing the default org in VS Code doesn't stick.

Restarting the VS Code extension host fixes both, until the next sleep.

Error Message

Error authenticating with the refresh token due to: login rate exceeded

System Information

{
  "architecture": "linux-x64",
  "cliVersion": "@salesforce/cli/2.153.5",
  "nodeVersion": "node-v22.22.1",
  "osVersion": "Linux 7.2.3-arch1-3",
  "rootPath": "~/.local/share/mise/installs/node/22.22.1/lib/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 4.0.2 (core)",
    "@oclif/plugin-commands 5.0.2 (core)",
    "@oclif/plugin-help 7.0.2 (core)",
    "@oclif/plugin-not-found 4.0.2 (core)",
    "@oclif/plugin-plugins 7.0.3 (core)",
    "@oclif/plugin-search 2.0.0 (core)",
    "@oclif/plugin-update 5.0.2 (core)",
    "@oclif/plugin-version 3.0.2 (core)",
    "@oclif/plugin-warn-if-update-available 4.0.1 (core)",
    "@oclif/plugin-which 4.0.1 (core)",
    "@salesforce/cli 2.153.5 (core)",
    "agent 2.2.2 (core)",
    "apex 4.3.0 (core)",
    "api 2.0.10 (core)",
    "auth 5.0.10 (core)",
    "code-analyzer 5.10.2 (user) published 221 days ago (Mon Mar 09 2026) (latest is 5.16.0)",
    "data 5.1.8 (core)",
    "deploy-retrieve 4.2.2 (core)",
    "info 4.0.10 (core)",
    "limits 4.0.5 (core)",
    "marketplace 2.0.6 (core)",
    "org 6.0.17 (core)",
    "packaging 3.0.7 (core)",
    "schema 4.0.7 (core)",
    "settings 3.0.7 (core)",
    "sobject 2.0.6 (core)",
    "telemetry 4.1.0 (core)",
    "templates 57.4.0 (core)",
    "trust 4.0.12 (core)",
    "user 5.0.6 (core)",
    "sfdx-git-delta 6.31.0 (user) published 245 days ago (Thu Feb 12 2026) (latest is 6.45.1)"
  ]
}

Additional Information

Suggested fix: file mtimes are real time, so use the real clock:

export const nowBigInt = (): bigint => BigInt(Date.now()) * 1_000_000n;

Code

Seen in Salesforce Extensions for VS Code 67.26.0 (bundles @salesforce/core 9.1.9) on Arch Linux. The code is unchanged on main.

Screenshots or Log Files

No response

Activity

  1. github-actions commented on Oct 16, 2026

    @github-actions

    Hello @mihapus 👋 None of the versions of sf you shared match the latest release.

    Shared: 2.153.5
    Latest: 2.154.4

    Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue.
    You can also try the rc and nightly releases! (docs)

    After updating, share the full output of sf version --verbose --json

  2. github-actions commented on Oct 16, 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.

  3. added
    more information requiredIssue requires more information or a response from the customer
    and removed
    investigatingWe're actively investigating this issue
    on Oct 16, 2026
  4. mihapus commented on Oct 16, 2026

    @mihapus
    Author

    Updated to the latest CLI and the bug is still there: @salesforce/cli/2.154.4 bundles @salesforce/core 9.3.0, which has the same nowBigInt.

    {
      "architecture": "linux-x64",
      "cliVersion": "@salesforce/cli/2.154.4",
      "nodeVersion": "node-v22.22.1",
      "osVersion": "Linux 7.2.3-arch1-3",
      "rootPath": "~/.local/share/mise/installs/node/22.22.1/lib/node_modules/@salesforce/cli",
      "shell": "bash",
      "pluginVersions": [
        "@oclif/plugin-autocomplete 4.0.2 (core)",
        "@oclif/plugin-commands 5.0.2 (core)",
        "@oclif/plugin-help 7.0.2 (core)",
        "@oclif/plugin-not-found 4.0.2 (core)",
        "@oclif/plugin-plugins 7.0.3 (core)",
        "@oclif/plugin-search 2.0.0 (core)",
        "@oclif/plugin-update 5.0.2 (core)",
        "@oclif/plugin-version 3.0.2 (core)",
        "@oclif/plugin-warn-if-update-available 4.0.1 (core)",
        "@oclif/plugin-which 4.0.1 (core)",
        "@salesforce/cli 2.154.4 (core)",
        "agent 2.2.2 (core)",
        "apex 4.3.4 (core)",
        "api 2.0.12 (core)",
        "auth 5.0.12 (core)",
        "code-analyzer 5.10.2 (user) published 221 days ago (Mon Mar 09 2026) (latest is 5.16.0)",
        "data 5.1.10 (core)",
        "deploy-retrieve 4.2.6 (core)",
        "info 4.0.13 (core)",
        "limits 4.0.6 (core)",
        "marketplace 2.0.7 (core)",
        "org 6.0.18 (core)",
        "packaging 3.0.8 (core)",
        "schema 4.0.8 (core)",
        "settings 3.0.8 (core)",
        "sobject 2.0.7 (core)",
        "telemetry 4.1.1 (core)",
        "templates 57.4.1 (core)",
        "trust 4.0.13 (core)",
        "user 5.0.7 (core)",
        "sfdx-git-delta 6.31.0 (user) published 245 days ago (Thu Feb 12 2026) (latest is 6.45.1)"
      ]
    }
  5. added
    validatedVersion information for this issue has been validated
    investigatingWe're actively investigating this issue
    and removed
    more information requiredIssue requires more information or a response from the customer
    on Oct 16, 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

    investigatingWe'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