-
Notifications
You must be signed in to change notification settings - Fork 30k
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
vscode.env.shell
might return empty string to extension if fetched very soon after startup
#160694
Comments
@Tyriar Looks like you should be using extension host init data for this, not a dynamic value that changes along the way |
@jrieken wouldn't that mean blocking the extension host launch on the pty host and its profile detection round trip? I believe this has always been like this and the value is dynamic depending on settings/environment. |
yes - either block or make it clear that the value changes, e.g we need an event to signal changes. I am not familiar with how this works, does the shell-value change during a single session? |
Changing the default shell (via settings or UI) will change the value. Let's track adding this API in this issue: export namespace env {
export const onDidChangeShell: Event<string>;
} |
Would an early-activating extension expect to receive this event when the value of As I understand it, for some modes of VS Code operation |
@gjsjohnmurray yes vscode/src/vs/base/common/async.ts Lines 438 to 455 in 9b80ed6
In the meantime I recommend you poll for the initial value and give up after some time, you may also want to re-check the value at a later point as well as it can change. |
@Tyriar Submitted a PR for this. Do you think that works? |
Leaving this open for future finalization |
@Tyriar from the activate method of the extension we call We're working around the problem by retrying the |
I think my job would have been easier if the |
Update since this was last discussed: the pty host now doesn't necessarily start up, however profiles are now always detected on the main/server procs, not the pty host: vscode/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts Lines 294 to 296 in 29d8134
Needs a final decision whether we want to block the exthost startup on terminal profile resolving. |
I measured the time it takes to
Caching it optimistically across sessions is a good idea though. Created #190974 to track that separately from the event. |
Can we put these numbers in perspective, e.g how about setting perf-markers so that they make it into telemetry so that we have a better view. 50ms isn't slow because from main, we start the renderer, we load the renderer code which are all opportunities to run this in parallel so that the results from |
Let's leave this issue open because |
I had a look at this and it's not as easy as I expected to get the profile in main as currently it depends upon the workspace and the renderer process evaluating parts of it before being handed off the the main process. I'm closing this as finalized because the issue where the initial value is an empty string is separate from the event API, plus it's tracked in the targeted issue #190974 |
Type: Bug
Seems to be a timing issue. The following steps sometimes reproduce it for me, but success may depend on the performance of your workstation (mine is Windows) and which other extensions are enabled by default.
npm install
ONLY Extension
configuration and run it. This launches with--disable-extensions
If this doesn't happen, try the next steps:
Extension
configuration instead. This launches normally and probably won't trigger the problem:Developer: Reload With Extensions Disabled
. With luck this will cause the problem to happen (see first screenshot).The extension activates
"*"
, so immediately on startup. The first attempt to getvscode.env.shell
happens from itsactivate
method.If the problem shows, click the status bar panel to get the value again. This time it should succeed.
VS Code version: Code - Insiders 1.72.0-insider (835ace5, 2022-09-12T05:16:16.290Z)
OS version: Windows_NT x64 10.0.22000
Modes:
Sandboxed: Yes
The text was updated successfully, but these errors were encountered: