-
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
Handle EH restart gracefully to avoid notebook working copy data loss #179224
Comments
The user experience is really really bad when this happens, I am glad we want to do something about it 👍 |
From our meeting, some action items:
|
Did a bit of experiments for these two and it's actually working great, as long as we don't hold a reference to notebook serializer object in the editor models, each time on save we just look up in the serializers map again for the latest serializer for a specific view type. Will experiment if we should always look up or we hold a ref but listen to serializer update events, will see. Screen.Recording.2023-04-05.at.2.31.33.PM.mov |
Awesome 👏 ! |
One feedback from @alexdima was to also look into the scenario of disabling the notebook extension with a dirty notebook editor:
Ideally the backup is held around for until we can show it in an editor and not remove it. I think today it gets dropped because the notebook editor opens but then fails to show the contents. |
What we have archived so far: Editor Open
In both cases, the working copy is not lost Install missing extension from editor open Screen.Recording.2023-04-12.at.10.41.43.AM.movEnable disabled extension from editor open Screen.Recording.2023-04-12.at.10.42.36.AM.movEditor SaveIf the serializer extension is disabled or doesn't exist when users attempt to save, we can now show an action in the prompt. The work is happening in #179727 Screen.Recording.2023-04-11.at.3.18.24.PM.movMore to improve
While testing all above scenarios, it seems working copies are kept if we don't intentionally dispose them in notebook, but I'm not sure if it's guaranteed, we might want to take a look together @bpasero in case I miss anything. End goal is no dirty working copy should be disposed by any means without user consent. |
This is 🚀 👏 cool work, thanks for pushing this forward. I wonder if we should also not dispose a notebook when it is not dirty. Because now the effect of a crashing extension host will be that non-dirty notebooks will just close at random. I would go ahead and simply never dispose notebooks when a view type goes away.
I think this needs to be level below: we need participation and veto support for EH restarts (except for when it crashes where we have no control). Because there are other reasons to restart the EH, for example entering a multi-root workspace.
To clarify: backups are meant to be kept unless we were able to open them in an editor (code pointer). We have to double check here if that works as advertised 👍
That is still on my list to investigate. |
#180204 offers an action to open the notebook as text file and will open as untitled if a backup is present showing that backup: |
* Cache view type provider for missing extension restore. * Re #179224. Customize action for save error. * polish * No delay for persisting view type memento * Use log service instead of console * dispose listener if extension installation/enablement fails --------- Co-authored-by: Benjamin Pasero <benjamin.pasero@gmail.com>
The only work left is #180514 , closing this issue. |
👍 , should probably have a test plan item for this work |
Does this issue occur when all extensions are disabled?: Yes/No
Over the past year, we've seen dozens of users report that they can't save notebooks or get the error "Can't read properties of undefined". We also got similar failures/errors from error telemetry or flaky integration tests. This issue in Jupyter microsoft/vscode-jupyter#11435 gave us good hints of what lead to this issue: EH crashed or restarted when there was a dirty notebook document in editors and things fell apart.
What happened under the hood
extHostCustomer
s were disposedNotebookSerializer
was disposed, which will remove thejupyter-notebook
view type.jupyter-notebook
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts#L570-L573NotebookSerializer
was disposed. TheNotebookSerializer
instance held arpc
proxy which was also disposed. There is no way to send the requests to anywhere to serialize the notebook document to bytes.NotebookEditorInput
was not disposed yet as the dirty document was not saved yet, thus itsNotebookEditorModel
/NotebookFileWorkingCopyModel
was not disposedNotebookFileWorkingCopyModel
can't resolve aNotebookTextDocument
as the serializer it used was disposed.Now users can't save the document, they can't restart the window either as the dirty notebook document can't be back'ed up. Their last option is discard the change. Even if the EH was restarted successfully, since the
NotebookFileWorkingCopyModel
was still using the legacy disposedNotebookSerializer
, they can't use the newNotebookSerializer
registered forjupyter-notebook
view type.Proposals
The main challenge here is most notebook serializers (the interactive window one is the only exception now) run in EH, if the EH is down, there isn't anything we can do as we rely on the serializer to do the data conversion. Users can potentially separate extensions to different EH instances to mitigate the issue (separate good and bad extensions) but usually when this happened, it was usually too late.
With that said, we should still explore what we can do to improve this, or minimize the impact. Some ideas from my explorations:
NotebookEditorInput
(which triggers Save) as we know it won't succeed. If the EH comes back within a reasonable threshold, re-establish the serializer to theNotebookFileWorkingCopy
so it can use the new serializer to save.@bpasero I'd like to hear your opinions on this and maybe brainstorm a bit on how we can improve this situation.
The text was updated successfully, but these errors were encountered: