Skip to content

fix: move GetLanguageService to async closure to prevent dispatch loop blocking#3016

Closed
SibtainOcn wants to merge 3 commits intomicrosoft:mainfrom
SibtainOcn:fix/formatter-stuck-dispatch-loop-blocking
Closed

fix: move GetLanguageService to async closure to prevent dispatch loop blocking#3016
SibtainOcn wants to merge 3 commits intomicrosoft:mainfrom
SibtainOcn:fix/formatter-stuck-dispatch-loop-blocking

Conversation

@SibtainOcn
Copy link

@SibtainOcn SibtainOcn commented Mar 7, 2026

.

…p blocking

Fixes #2857

The formatter gets stuck because GetLanguageService runs synchronously on the
dispatch loop thread and blocks on snapshotUpdateMu. When this mutex is held
by another operation (e.g. DidOpenFile, idle cache clean timer, or concurrent
snapshot updates), the dispatch loop stalls and no responses can be sent.

This is most visible with format-on-save, since the save notification triggers
snapshot updates that compete for the same lock the formatting handler needs.

Moving GetLanguageService into the async closure allows the dispatch loop to
remain responsive while the language service is being acquired in a goroutine.
@jakebailey
Copy link
Member

Does this not just undo #2765?

@SibtainOcn SibtainOcn closed this Mar 9, 2026
@SibtainOcn SibtainOcn reopened this Mar 9, 2026
@SibtainOcn SibtainOcn closed this Mar 9, 2026
@SibtainOcn SibtainOcn deleted the fix/formatter-stuck-dispatch-loop-blocking branch March 9, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants