Skip to content

Create extension host processes from a node worker in the main process#135774

Merged
alexdima merged 23 commits intomainfrom
alex/main-process-extension-host
Nov 11, 2021
Merged

Create extension host processes from a node worker in the main process#135774
alexdima merged 23 commits intomainfrom
alex/main-process-extension-host

Conversation

@alexdima
Copy link
Member

@alexdima alexdima commented Oct 25, 2021

Fixes #123592: Creates a node worker in the main process which creates extension host processes.

@alexdima alexdima added this to the October 2021 milestone Oct 25, 2021
@alexdima alexdima self-assigned this Oct 25, 2021
@alexdima alexdima added the extension-host Extension host issues label Oct 27, 2021
@alexdima alexdima modified the milestones: October 2021, November 2021 Oct 28, 2021
@bpasero
Copy link
Member

bpasero commented Nov 10, 2021

@alexdima looks a lot better now in CI, 👏 . maybe as a next step you restore the worker approach for forking the extension host?

@alexdima alexdima merged commit 37794df into main Nov 11, 2021
@alexdima alexdima deleted the alex/main-process-extension-host branch November 11, 2021 16:51
import { IExtensionHostStarter, ipcExtensionHostStarterChannelName } from 'vs/platform/extensions/common/extensionHostStarter';

registerSharedProcessRemoteService(IExtensionHostStarter, ipcExtensionHostStarterChannelName, { supportsDelayedInstantiation: true });
const location = 'main' as 'main' | 'shared';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code mean that for now, we don't register the shared process remote service anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to have an easy way to switch between the main process spawning the extension host and the shared process spawning the extension host. Currently, this means the extension host is spawned from the main process.

}

onDynamicStdout(id: string): Event<string> {
return this._proxy!.onDynamicStderr(id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be onDynamicStdout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

}
const pid = this._process.pid;
this._logService.info(`Waiting for extension host with pid ${pid} to exit.`);
await Promise.race([Event.toPromise(this.onExit), timeout(maxWaitTimeMs)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: we are not explicitly terminating the extension host here because we assume that the window is closing which will close the socket and then should trigger the self-termination from within the extension host?

I wonder if maybe a more explicit flow should be implemented where you terminate the extension host from here, because once we move to a different IPC mechanism in the future, maybe we cannot rely on the socket-close event anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to revisit the shutdown of the extension host. Today, the extension host shuts down when the renderer sends it a shutdown message via the socket or when the socket closes. If the new IPC mechanism does not support closing we need to find an alternative way to shutdown the extension host (maybe by posting a message using nodejs to it).

@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

extension-host Extension host issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move extension host out of the workbench for process reuse

3 participants