[BUG]: Config and auth changes are silently lost after the computer sleeps
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
The report points to src/util/time.ts, src/config/configFile.ts, and src/org/authInfo.ts in sfdx-core. Read the timestamp helper and the merge logic, then check the related tests for config and auth writes. Reproduce the sleep-related clock lag and verify that updated config and refreshed auth values persist after waking the computer.
由索引模型根据 Issue 内容生成。
描述
Before You Submit
- I'm using the latest version of Salesforce CLI
- I've searched the existing issues
- I've run
sf doctorto 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:11performance.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
- Run:
node -e 'setInterval(()=>console.log("lag ms:", Date.now()-(performance.timeOrigin+performance.now())), 5000)' - Put the computer to sleep for a few minutes, then wake it.
- The lag jumps by the sleep time.
@salesforce/coreuses 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
refreshFnhands 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
- https://github.com/forcedotcom/sfdx-core/blob/e8bb48e8203371d2b37f7c1545cb7b346b53347e/src/util/time.ts#L18-L19
- https://github.com/forcedotcom/sfdx-core/blob/e8bb48e8203371d2b37f7c1545cb7b346b53347e/src/config/configFile.ts#L250-L257
- https://github.com/forcedotcom/sfdx-core/blob/e8bb48e8203371d2b37f7c1545cb7b346b53347e/src/org/authInfo.ts#L1152-L1184
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
- 主要语言
- 没有语言数据
- 星标
- 571
- 派生
- 80
- 平均合并
- 23 小时 43 分钟
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
forcedotcom/cli 的其他 Issue
-
sf agent mcp asset replace --assets null throws raw TypeError instead of InvalidShape可能已有人在做 @konkonrong-lgtm 于 70 天前认领。 未关闭area:afdx bug investigating owned by another team validated
难度 2/5 1-3 小时 新手友好度 78/100
forcedotcom/cli#3625 · 4 条评论 ·
-
area:afdx bug owned by another team
难度 2/5 1-3 小时 新手友好度 78/100
forcedotcom/cli#3608 · 2 条评论 ·
-
[BUG]: sf package version create always warns about org-capitalize-record-types, even when it's set未关闭area:packaging more information required owned by another team regression stale
难度 3/5 1-2 天 新手友好度 52/100
forcedotcom/cli#3663 · 5 条评论 ·
-
[BUG]: NavigationMenu SourceMember name mismatch prevents source-tracked retrieve from completing未关闭bug investigating validated
难度 4/5 3-5 天 新手友好度 52/100
forcedotcom/cli#3660 · 3 条评论 ·
-
announcement
难度 5/5 一周以上 新手友好度 25/100
forcedotcom/cli#3658 · 1 个 reaction ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
awslabs/visual-asset-management-system#537 ·
维护者通常 1 天内回复
-
bug iam-service
难度 2/5 1-3 小时 新手友好度 76/100
platform-mesh/platform-mesh#425 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
grafana/tempo-operator#1691 ·
维护者通常 1 天内回复
-
enhancement
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复