Closed
Description
Synopsis
We allow the extension host to be restarted in certain cases. Today this happens without any support for asking components whether they can support a restart and so issues arise.
#180513 introduces a new IExtensionService.onWillStop
event that listeners can veto(boolean | Promise<boolean>)
, for example:
// sync
extensionService.onWillStop(e => e.veto(true, 'component id'));
// async
extensionService.onWillStop(e => e.veto(Promise.resolve(true), 'component id'));
This allows to:
- veto the restart and thus prevent it
- prolong the restart until work has finished without preventing the restart
In addition the method IExtensionService.stopExtensionHosts()
is now a Promise<boolean>
and callers must await the result before proceeding. For example:
const stopped = await this.extensionService.stopExtensionHosts();
if (!stopped) {
return;
}
Related Issues
Some components cannot support EH restart without doing some operation first before the EH goes down, for example:
- Data loss: Custom editors do not properly deal with extension host restarts #122992
- Handle EH restart gracefully to avoid notebook working copy data loss #179224
Adoption
- Notebook component should make sure dirty and untitled notebooks are saved before the EH restarts @rebornix
- Custom editor component should make sure dirty and untitled custom editors are saved @mjbvz
- Workspace trust needs to adopt the new
boolean
return type ofstopExtensionHosts
here @lszomoru - Profiles need to adopt the new
boolean
return type ofstopExtensionHosts
here @sandy081