fix(typecheck-worker): avoid false-positive willTypecheck
s on Linux
#1198
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.
We've seen occasional timeouts in CI for our test that verifies we don't block builds for file changes that don't trigger a new typecheck. Interestingly, these timeouts have never occurred on Windows, and I've also never managed to reproduce them locally on my Mac, but they pretty reliably occur every 3-4 runs on Linux.
Digging in (by running the offending test in a loop in CI), it seems that the change to a
.hbs
file is occasionally causing TypeScript'screateProgram
to be called, but then subsequently short circuited as some other piece of machinery discovers that the change in question doesn't matter. This is a problem for us, as we treatcreateProgram
as proof that a typecheck has started, and ifafterProgramCreate
is never subsequently called, then our worker just sits on a pending promise forever.Fortunately for us, when
afterProgramCreate
is called, it's called synchronously near the end ofcreateProgram
, so from the perspective of the outside world, it doesn't matter if we callwillTypecheck
increateProgram
orafterProgramCreate
: no events will be dispatched in between those two functions anyway.