Repository navigation
Avoid timeouts in mirroring terminals to the extension host - #113938
Merged
Merged
Conversation
… host by assigning a temporary UUID to terminals created on the extension host side
Daniel Imms (Tyriar)
approved these changes
Jan 7, 2021
Daniel Imms (Tyriar)
left a comment
Contributor
There was a problem hiding this comment.
Champion 🏆
Looks great, thanks for diving deep into this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #112446
I believe that the flakiness that we see in integration tests is caused by the
setTimeoutcall in theonInstanceCreatedlistener. 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$acceptTerminalOpenedarrives. This might introduce flakiness if_getTerminalByIdEventuallyends up consiming its 5 retries.The reason the
setTimeoutcall 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$acceptTerminalOpenedwould fire before the$createTerminalwould return, which would lead to the extension host having twoExtHostTerminalinstances 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
$sendTextor$showwhich now accept either the numeric renderer generated id or the newly introduced temporary UUID).On the renderer side, the temporary UUID is called
extHostTerminalIdand is part of the launch config. Its only purpose is to correlate anonInstanceCreatedevent with the terminal instance created on the extension host side. That is why on the extension host side,$acceptTerminalOpenednow receives the renderer numeric id and (if the terminal was created by an extension host), theextHostTerminalIdUUID. 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.