fatal error: concurrent map read and map write
goroutine 70 [running]:
github.com/artmoskvin/hide/pkg/lsp.(*ServiceImpl).updateDiagnostics(...)
/Users/artemm/Code/hide/pkg/lsp/service.go:280
github.com/artmoskvin/hide/pkg/lsp.(*ServiceImpl).listenForDiagnostics(0x140002222a0, {0x14000096800, 0xa}, 0x140002c6690)
/Users/artemm/Code/hide/pkg/lsp/service.go:274 +0x190
created by github.com/artmoskvin/hide/pkg/lsp.(*ServiceImpl).StartServer in goroutine 21
/Users/artemm/Code/hide/pkg/lsp/service.go:117 +0x9a4
...
I suspect that the culprit is the diagnostics map that we use to store project diagnostics. During shutdown, we remove all diagnostics and terminate LSP server processes. Apparently, one of the last steps for LSP server before termination is to send empty diagnostics (presumable to clean up all highlights in text editors) which results in the concurrent access conflicting with the shutdown procedure.
Sometimes the shutdown fails with:
I suspect that the culprit is the diagnostics map that we use to store project diagnostics. During shutdown, we remove all diagnostics and terminate LSP server processes. Apparently, one of the last steps for LSP server before termination is to send empty diagnostics (presumable to clean up all highlights in text editors) which results in the concurrent access conflicting with the shutdown procedure.