[WIP / Please Comment] Remove Asynchrony / Fix Races? #343 #368
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.
Hi 71 -
I took the liberty of checking out the code and seeing if I could address this keypresses racing issue (#343). The first thing I noticed is that the very start of the keypress handling stack is asynchronous. What I've learned is that
awaiting a concrete value still yields to the scheduler. So, we should avoid asyncs or awaits in the keypress stack.As a first pass, I simply removed the await here. Because of the use of the unknown type, I can't identify which values were promises and which were concrete, but it passes the entire test suite and my initial experimentation hasn't indicated any problems yet. I thought maybe you would be able to comment on where asynchrony is actually needed.
If we do need to maintain asynchrony, it should be easy to use a conditional to either await or return; this may require restructing a little bit in the very top of the stack where we install handlers to the extension.
I'm going to try building this and installing it on my main VSCode to see if it fixes the problem and/or causes new problems, since it's extremely difficult to properly test this behavior. Can you let me know if I'm on the right track?
Thank you!