-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Intl.DateTimeFormat().resolvedOptions().locale" returns different values in extension host to VS Code process #85675
Comments
I don't think we have any code to reset/remove things. @deepak1556 Do you have any ideas? (the extension host is using |
FWIW we've worked around this in Flutter. It still seems weird these don't line up and it might be useful for the extension host to have access to it, but it's not pressing for me anymore. Thanks! |
I can confirm this issue, @alexandrudima here are my observations.
To make things more concrete, v8 and icu are shared between node and electron so behavior being different between these two processes are highly unlikely unless we are intervening. |
Okay I have narrowed down the issue, it seems to be a problem with
prints |
Confirmed the issue still occurs on the latest Insiders on Big Sur. |
I copied the code from #85675 (comment) to a file
Keeping the Electron label on this issue. |
Electron actually reports the locale properly if one changes the {
...process.env,
'ELECTRON_RUN_AS_NODE': 1
} Even if we were to spawn just node, I noticed that providing A second issue is the user must set the For the first issue, we already use vscode/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts Line 215 in 724181f
Therefore, we aren't forgetting to add |
So I first thought the issue was as-designed, because my minimal repro was a bit too minimal, but it's actually a more generic upstream issue. Minimal repro: main.js const { app, BrowserWindow } = require('electron');
const cp = require('child_process');
// If we ask for the locale before the app is ready, we actually get en-US here, too.
app.whenReady().then(() => {
console.log(Intl.DateTimeFormat().resolvedOptions().locale);
const proc = cp.fork(__dirname + '/child.js');
proc.on('exit', () => app.quit());
}) child.js
Output on macOS with the language set to Spanish (Latin America):
|
In the past week, I learned that
My plan now is to fetch the locale before spawning the extension host, and pass the locale in as an environment variable. I'll also merge it in next iteration to get more testing. |
Here's the current situation:
Therefore, I'll mark this issue as a wontfix for now. |
I'm using MacBook with its system language set to en-GB. I launched VS Code (from the dock, not the terminal) and if I run:
in the Chrome dev tools console, I see this:
However, in an extension's activate function if I do this:
Then I see this:
I need to get the system language in order to set the
LANG
env variable for spawned processes because CocoaPods crashes ifLANG
is not set to something-UTF-8, and there's no way to set it without a language part so I need to get at the system language.The text was updated successfully, but these errors were encountered: