Skip to content

Avoid timeouts in mirroring terminals to the extension host - #113938

Merged
Daniel Imms (Tyriar) merged 2 commits into
masterfrom
alex/terminal-exthost-improvements
Jan 7, 2021
Merged

Daniel Imms (Tyriar) merged 2 commits into
masterfrom
alex/terminal-exthost-improvements

Conversation

@alexdima

Copy link
Copy Markdown
Member

Fixes #112446

I believe that the flakiness that we see in integration tests is caused by the setTimeout call in the onInstanceCreated listener. This timeout leads to a lot of complicated code on the extension host side, where other terminal events could overtake and arrive at the extension host before $acceptTerminalOpened arrives. This might introduce flakiness if _getTerminalByIdEventually ends up consiming its 5 retries.

The reason the setTimeout call was introduced was basically due to terminals constructed on the extension host side. These terminals are instantiated immediately on the extension host side and they do not have a chance to read up their renderer generated id in time, because $acceptTerminalOpened would fire before the $createTerminal would return, which would lead to the extension host having two ExtHostTerminal instances representing the same renderer side terminal.

In this PR, I suggest a different approach, where the extension host generates a temporary UUID to terminals created on the extension host side. Then, the extension host side can communicate to the main thread side using either the renderer numeric id or also using these temporary UUIDs (see for example $sendText or $show which now accept either the numeric renderer generated id or the newly introduced temporary UUID).

On the renderer side, the temporary UUID is called extHostTerminalId and is part of the launch config. Its only purpose is to correlate an onInstanceCreated event with the terminal instance created on the extension host side. That is why on the extension host side, $acceptTerminalOpened now receives the renderer numeric id and (if the terminal was created by an extension host), the extHostTerminalId UUID. Since we are dealing with multiple extension hosts, only a matching UUID is looked up and, if found, gets its id replaced with the numeric renderer id.

… host by assigning a temporary UUID to terminals created on the extension host side

@Tyriar Daniel Imms (Tyriar) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Champion 🏆

Looks great, thanks for diving deep into this!

@Tyriar Daniel Imms (Tyriar) added this to the January 2021 milestone Jan 7, 2021
@Tyriar
Daniel Imms (Tyriar) merged commit 16452c5 into master Jan 7, 2021
@Tyriar
Daniel Imms (Tyriar) deleted the alex/terminal-exthost-improvements branch January 7, 2021 17:29
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky integration test: Terminal window.onDidWriteTerminalData should listen to all future terminal data events

2 participants