This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
Ensure LSP readLoop doesn't block shutdown - #1074
Merged
Merged
Conversation
Jake Bailey (jakebailey)
requested review from
Copilot and
Gabriela Araujo Britto (gabritto)
June 5, 2025 23:12
Merged
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR prevents the readLoop from blocking process shutdown by running it in a standalone goroutine and tweaks the error check on g.Wait().
- Extract
readLoopout of the error group so it’s not tied to the group’s cancellation. - Spawn
readLoopin a fire-and-forget goroutine and suppress its error. - Refine the
g.Wait()error condition to also checkctx.Err().
Comments suppressed due to low confidence (1)
internal/lsp/server.go:201
- Requiring
ctx.Err() != nilin the error check may suppress genuine errors fromdispatchLooporwriteLoopwhen the context hasn't been cancelled. Consider reverting to the original condition (err != nil && !errors.Is(err, io.EOF)) to ensure you don’t miss critical failures.
if err := g.Wait(); err != nil && !errors.Is(err, io.EOF) && ctx.Err() != nil {
| return err | ||
| } | ||
| }) | ||
| go func() { readLoopErr <- s.readLoop(ctx) }() |
Member
Author
There was a problem hiding this comment.
This goroutine can leak if the reader never exits, but I'm trying to handle the case where the process is exiting due to a cancellation cancel via a signal, so, it's hard to do better here without cancelable stdin reads
Gabriela Araujo Britto (gabritto)
approved these changes
Jun 5, 2025
Jake Bailey (jakebailey)
enabled auto-merge
June 5, 2025 23:22
Jake Bailey (jakebailey)
added a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
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.
Sort of pulled out of #991, but I'm hoping this helps people who are seeing their
tsgoprocesses not exit.The next measure we could take is to watch the parent process (PID is given during init) and exit if it exits.