-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Investigation: do not restart Extension host when first folder changes #69335
Comments
This is affecting Live Share because they want to be able to track workspace changes during a live share session. If the EH reloads, then the host will have to restart their session. If we wanted to more aggressively deprecate FYI @cait1inhennessy |
As a workaround, they can keep a dummy folder in the workspace during a session, but the user needs to know to not touch that folder, so it's not a very good workaround. |
To be clear: the transition from an empty window or single-folder workspace to a multi-root workspace will always require an extension host restart because the workspace ID changes and thus the state location for example. Please check with them if they really start from an empty workspace and then add a folder. |
Yeah, we realized that, and they are able to start from an actually empty workspace. I think that if you cause a window reload, it will at least be obvious why your liveshare session terminated. |
I am all up for making this change, but we have to decide if:
I feel the former is a change with more impact on todays extensions compared to the latter. From the API /**
* ~~The folder that is open in the editor. `undefined` when no folder
* has been opened.~~
*
* @deprecated Use [`workspaceFolders`](#workspace.workspaceFolders) instead.
*/
export const rootPath: string | undefined; I think we need to bring this up in an API call to decide, but I will not have cycles. This needs a champion to drive. |
I think we need an idea of how many extensions this would affect. @sandy081 I am using your tool but it seems to be showing me old versions of extensions that used this api, how do I limit it to newer versions? I think the first option would actually be less impactful. It would mean that some extensions can't work in a multiroot workspace, but they should handle the case of no folder already for an empty window. The second option would break an assumption that those extensions may be making, that rootPath will not change, and we don't know what that would do. I can bring it up in an API call. @cait1inhennessy we will discuss it some more because I think this is the right change to make, but don't count on us changing it this month, you will probably have to plan to use the workaround with a dummy folder in the short term. |
@roblourens What is your thinking when the first workspace-folder isn't a folder on disk. E.g what would |
Oh, ignore my last comment...
From what I remember when we checked back then extensions often show a message like "Open a folder first" |
Yes, now that I think about it, I would also prefer that |
step 1: know how many users use multi root workspaces and could be affected by this |
@roblourens feel free to delete
If you cannot reserve time this milestone, feel free to move back to me "On Deck". |
Since this is a high risk change I would not do anything else than gathering data this milestone. Maybe show an aggressive prompt when developing extensions that use this API. Also adding @dbaeumer since I believe that the LSP-client has a reason to use the API (maybe not anymore?) |
@roblourens I just nudged those issues you raised a year ago. |
Does this deserve to be on a milestone? For a while during 2020 it was. |
I think the latest status is still #69335 (comment). Don't know whether anything came out of @dbaeumer's discussions. Still not a lot of activity on the affected extensions it seems. |
Actually I am not sure. Lets ping @egamma again. @egamma please see: #69335 (comment) |
In the light of data loss issues such as #122992 I really think we should stop restarting extension hosts. |
I'd like to ask for clarity on this as I'm seeing an issue with the extension I am working on. What exactly does "first folder changes" mean? We have an operation that adds a new folder to VSCode and if we do that in an empty or non-empty saved workspace then the extension host seems to restart all the extensions. The folder does appear at the top of the workspace list. Is that this issue? Is there anything we can do about it? Or should extensions be resilient to restarts? We're seeing "retain context when hidden" webviews being left unresponsive as they are associated with the previously extension "run time" or "instance". |
When your operation adds a folder to a workspace that already has at least one folder, does the new folder get added in first position, pushing the other folders down? If so, try changing how you call the API to add the folder. For instance, append it. |
Thank you @gjsjohnmurray. Kind of you to take the time. I have just found the docs on it and realise that it is documented: https://code.visualstudio.com/api/references/vscode-api#workspace.updateWorkspaceFolders - we'll change our approach accordingly. Though I guess it might still cause issues for the first folder added. |
@bpasero Perhaps this can be implemented risk-free by using an opt-in boolean: canHandleNotHavingARootPathWhenInWorkspace: true (obviously different name). |
@roblourens Could you please clarify why this is not considered important anymore? |
Today we restart the extension host whenever the first folder changes because
workspace.rootPath
is always set to that first folder and it never used to change after the extension host started once.If we would not restart the extension host anymore an extension:
workspace.rootPath
as before, it would still point to the first folder always (which can beundefined
if the workspace contains no folders)onDidChangeWorkspaceFolders
event to get notified about updatesworkspace.rootPath
changing during runtime whenever the first folder changes//cc @sandy081 @jrieken
The text was updated successfully, but these errors were encountered: