[BUG]: API version cache never hits under a non-US locale: `instanceApiVersionLastRetrieved` is written with `toLocaleString()` and read with `Date.parse`, so every command runs the My Domain DNS check
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 74/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- javascript, node.js
Piste de recherche
Le rapport identifie Connection.retrieveMaxApiVersion() et getCachedApiVersion() comme les chemins d’écriture et de lecture ; commencez par localiser ces méthodes et leurs tests dans le CLI ou le code source du core fourni. Vérifiez comment l’horodatage est écrit et analysé, puis ajoutez des tests pour une locale autre que celle des États-Unis. Le travail est terminé lorsque le cache de la version de l’API reste valide pendant 24 heures d’une locale à l’autre et que les commandes répétées évitent la requête DNS supplémentaire.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
#3425 (the same API-version re-check path, for an org a command does not need; fixed in 2.123.1)
Command
any command that uses an org, e.g. sf data query -o <alias> -q "SELECT Id FROM Organization"
Org Type
Scratch Org
Did this work before?
Not sure
Last Working Version
No response
Summary
Connection.retrieveMaxApiVersion() caches the org's API version in the auth file with instanceApiVersionLastRetrieved: new Date().toLocaleString(), and getCachedApiVersion() reads that back with Date.parse(). toLocaleString() follows the process locale, and Date.parse() reads US-style dates. Under LANG=en_GB.UTF-8 the date is written 25/10/2026, 20:58:29, which parses to NaN, so the cache never hits.
So every command fetches the API version again, and first runs the My Domain DNS check (isResolvable() → MyDomainResolver, 3 s by default). One slow DNS answer then fails the command with DomainNotFoundError: The org cannot be found, though the org is fine: it stopped a three-hour test harness that makes an sf call about every ten seconds.
On the 1st to the 12th of a month, the same string parses with day and month swapped. Written on 10 May (10/05/2026), it reads as 5 October: in the future, so the cache does not expire for months. Written on 5 October (05/10/2026), it reads as 10 May, so it is always stale.
Repository to Reproduce
none needed: the root cause needs only node, and the effect any authenticated org.
Steps to reproduce
- The root cause, no org:
LANG=en_GB.UTF-8 node -e "const s=new Date(2026,9,25,20,58,29).toLocaleString(); console.log(s, Date.parse(s))" # 25/10/2026, 20:58:29 NaN LANG=en_GB.UTF-8 node -e "const s=new Date(2026,4,10,9,0,0).toLocaleString(); console.log(s, new Date(Date.parse(s)).toISOString())" # 10/05/2026, 09:00:00 2026-10-05T… (10 May read as 5 October) - The effect, with an org: run the same command twice per locale with debug logging. After each command, count the
Attempting to resolve urllines the day's log gained:L=~/.sf/sf-$(date +%Y-%m-%d).log for loc in en_GB.UTF-8 en_GB.UTF-8 en_US.UTF-8 en_US.UTF-8 en_GB.UTF-8 en_GB.UTF-8; do b=$(grep -c "Attempting to resolve url" $L) LANG=$loc SF_LOG_LEVEL=debug sf data query -o <alias> -q "SELECT Id FROM Organization" --json > /dev/null echo "$loc $(( $(grep -c "Attempting to resolve url" $L) - b )) lookups; cache: $(jq -r .instanceApiVersionLastRetrieved ~/.sfdx/<username>.json)" done
Expected Result
After the first command, the API version comes from the cache for 24 hours, whatever the locale, and no DNS check runs.
Actual Result
Measured 2026-10-25 on 2.155.7 with the loop above, against a scratch org:
en_GB.UTF-8 2 lookups; cache: 25/10/2026, 23:24:04
en_GB.UTF-8 2 lookups; cache: 25/10/2026, 23:24:06
en_US.UTF-8 1 lookups; cache: 10/25/2026, 11:24:07 PM
en_US.UTF-8 0 lookups; cache: 10/25/2026, 11:24:07 PM
en_GB.UTF-8 0 lookups; cache: 10/25/2026, 11:24:07 PM
en_GB.UTF-8 0 lookups; cache: 10/25/2026, 11:24:07 PM
Under en_GB, every command looks the org up twice and rewrites the cache date. Once an en-US date is written, en_GB reads it, until the 24 hours run out and the date is written in GB form again.
Error Message
What one slow DNS answer does to a command that runs the check. Here the slow answer is simulated: a --require hook delays dns.lookup of the org's host by 5 s, and SFDX_IGNORE_API_VERSION_CACHE=true makes the check run as the locale bug does. The real slow answer, on 2.138.6, stopped an sf project deploy start with the same error.
$ SFDX_IGNORE_API_VERSION_CACHE=true sf data query -o <alias> -q "SELECT Id FROM Organization"
Error (DomainNotFoundError): Parsing --target-org
The org cannot be found
Workaround: SFDX_DNS_TIMEOUT=30 (the same call: exit 0 after 22 s, the record returned). Not SF_DNS_TIMEOUT, which does nothing: see Additional Information.
System Information
{
"architecture": "linux-x64",
"cliVersion": "@salesforce/cli/2.155.7",
"nodeVersion": "node-v24.14.0",
"osVersion": "Linux 6.8.0-93260105-generic",
"rootPath": "<cut>",
"shell": "bash",
"pluginVersions": [
"@oclif/plugin-autocomplete 4.0.4 (core)",
"@oclif/plugin-commands 5.0.4 (core)",
"@oclif/plugin-help 7.0.4 (core)",
"@oclif/plugin-not-found 4.0.4 (core)",
"@oclif/plugin-plugins 7.0.7 (core)",
"@oclif/plugin-search 2.0.0 (core)",
"@oclif/plugin-update 5.0.4 (core)",
"@oclif/plugin-version 3.0.5 (core)",
"@oclif/plugin-warn-if-update-available 4.0.3 (core)",
"@oclif/plugin-which 4.0.4 (core)",
"@salesforce/cli 2.155.7 (core)",
"agent 2.2.2 (core)",
"apex 4.4.3 (core)",
"api 2.0.17 (core)",
"auth 5.0.16 (core)",
"data 5.1.16 (core)",
"deploy-retrieve 4.2.14 (core)",
"info 4.0.16 (core)",
"limits 4.0.6 (core)",
"marketplace 2.0.17 (core)",
"org 6.0.26 (core)",
"packaging 3.0.14 (core)",
"schema 4.0.12 (core)",
"settings 3.0.14 (core)",
"sobject 2.0.12 (core)",
"telemetry 4.2.0 (core)",
"templates 57.4.6 (core)",
"trust 4.0.20 (core)",
"user 5.0.11 (core)"
]
}
Additional Information
- Suggested fix: write the date as
new Date().toISOString().Date.parse()reads ISO 8601 in every locale. A date already written in the old form is replaced the next time it reads as stale, but one that parsed into the future holds until that date. SF_DNS_TIMEOUTis ignored. SettingSFDX_DNS_TIMEOUTmakes sf warn "Deprecated environment variable: SFDX_DNS_TIMEOUT. Please use SF_DNS_TIMEOUT instead.", butsrc/status/myDomainResolver.tsreads onlynew Env().getNumber('SFDX_DNS_TIMEOUT', 3). WithSF_DNS_TIMEOUT=30and noSFDX_DNS_TIMEOUT, the Error Message call above fails at 7.3 s, as with neither set. Measured on 2.155.7 and 2.138.6. So following the warning puts the timeout back to 3 s, and nothing says so.- Node's default locale (ICU) follows
LC_ALL, thenLC_MESSAGES, thenLANG.LC_TIMEalone does not change it. Not measured on macOS or Windows. - Ubuntu 24.04.3 LTS, bash,
LANG=en_GB.UTF-8. Bundled@salesforce/core9.3.6. Also seen on 2.138.6 (core 8.31.0). Also seen against a production Dev Hub, not only scratch orgs.
Screenshots or Log Files
No response
- Langage dominant
- Aucune donnée de langage
- Étoiles
- 574
- Forks
- 80
- Merge moyen
- 14 h 43 min
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de forcedotcom/cli
-
sf agent mcp asset replace --assets null throws raw TypeError instead of InvalidShapePeut-être pris @konkonrong-lgtm l’a pris il y a 78 jours. Ouvertearea:afdx bug investigating owned by another team validated
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
forcedotcom/cli#3625 · 4 commentaires ·
-
area:afdx bug owned by another team
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
forcedotcom/cli#3608 · 2 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
forcedotcom/cli#3670 · 1 commentaire ·
-
announcement
Difficulté 1/5 Moins d'une heure Accessibilité débutants 1/100
forcedotcom/cli#3668 ·
-
bug investigating validated
Difficulté 3/5 1-2 jours Accessibilité débutants 66/100
forcedotcom/cli#3667 · 5 commentaires ·
Toutes les issues de forcedotcom/cli
Issues similaires
-
fix: reject sourceStorage/packagedStorage bucket that differs from the stack default (fail loud)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Eyevinn/open-videocore#1300 ·
Les mainteneurs répondent en général sous 1 jour
-
nextjs-tracking
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
cloudflare/vinext#4390 ·
Les mainteneurs répondent en général sous 1 jour
-
priority: p2 type: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
googleapis/java-genai#1372 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug] Dashboard renders attachment links that resolve to 404 when the FILES binding is absentOuvertebug 優先: 低
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
fix: heartbeat wakes every participants long-poll (emit users:change only on state transition)Peut-être pris @birme l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Eyevinn/intercom-manager#425 ·
Les mainteneurs répondent en général sous 1 jour