microsoft/typescript-go · info
failed to refresh diagnostics: %w
Error message
failed to refresh diagnostics: %w
What it means
RefreshDiagnostics (server.go:308-325) failed to send the fire-and-forget workspace/diagnostic/refresh request: the client advertised diagnostics refresh support, but queueing the outgoing server->client request onto the outgoing queue (s.send via outgoingQueue.Put with the background context) errored. Because the request is fire-and-forget, client-side failures never produce this error — only local send/queue failures do.
Source
Thrown at internal/lsp/server.go:321
return fmt.Errorf("no file watcher exists with ID %s", id)
}
// RefreshDiagnostics implements project.Client.
func (s *Server) RefreshDiagnostics(ctx context.Context) error {
if !s.clientCapabilities.Workspace.Diagnostics.RefreshSupport {
return nil
}
if err := ctx.Err(); err != nil {
return err
}
// Fire-and-forget: the client always returns null, and waiting for the response
// can cause the server to hang if the client is slow or unresponsive.
// Any response from the client will be silently ignored by the read loop.
if err := sendClientRequestFireAndForget(s, lsproto.WorkspaceDiagnosticRefreshInfo, lsproto.NoParams{}); err != nil {
return fmt.Errorf("failed to refresh diagnostics: %w", err)
}
return nil
}
// PublishDiagnostics implements project.Client.
func (s *Server) PublishDiagnostics(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error {
return sendNotification(s, lsproto.TextDocumentPublishDiagnosticsInfo, params)
}
// SendTelemetry implements project.Client.
func (s *Server) SendTelemetry(ctx context.Context, telemetry lsproto.TelemetryEvent) error {
if !s.telemetryEnabled {
panic("SendTelemetry called with telemetry disabled")
}
return sendNotification(s, lsproto.TelemetryEventInfo, telemetry)
}
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Treat as mostly benign: the refresh is optional UX; on send failure the client will re-pull diagnostics on the next change anyway.
- If it recurs mid-session, check writer health — this error implies the outgoing queue could not accept the message (stream broken or shutting down).
- Guard call sites so refresh failures never abort larger operations (they are advisory notifications).
- During shutdown paths, skip or ignore the error when the background context is canceled.
Example fix
// before
if err := client.RefreshDiagnostics(ctx); err != nil { return err }
// after: advisory refresh must not fail the operation
if err := client.RefreshDiagnostics(ctx); err != nil {
log.Printf("diagnostics refresh skipped: %v", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// capability check mirrors the server's own guard
func supportsRefresh(caps *lsproto.ResolvedClientCapabilities) bool {
return caps.Workspace.Diagnostics.RefreshSupport
}
if supportsRefresh(&clientCaps) {
if err := client.RefreshDiagnostics(ctx); err != nil {
log.Printf("diagnostics refresh failed: %v", err)
}
} Type guard
func refreshSafe(ctx context.Context) bool {
return ctx.Err() == nil // avoid queueing refreshes during shutdown
} Try / catch
if err := client.RefreshDiagnostics(ctx); err != nil {
if ctx.Err() != nil || shuttingDown() {
// queue closed during teardown: expected, ignore
return nil
}
log.Printf("diagnostics refresh skipped: %v", err)
} Prevention
- Treat refresh requests as advisory; never let their failure abort an operation.
- Avoid triggering refreshes once shutdown begins (ctx canceled).
- If refreshes fail mid-session, check writer/stream health — the outgoing queue rejects messages only when broken or closing.
When it happens
Trigger: The outgoing queue is closed/drained during server shutdown, the writer has failed (broken stream), or the background context is canceled while the message is queued. The refresh is sent without waiting for a response per the comment at server.go:317-319, so no client response error can be the cause.
Common situations: Refresh racing server shutdown; the editor closed the connection while a project reload triggered diagnostics refresh; test servers with in-memory pipes closed early.
Related errors
- failed to refresh inlay hints: %w
- failed to refresh code lens: %w
- Invalid value for ${name}: ${value}
- forRelease requires setPrerelease unless nativePreviewReleas
- Language client is not initialized
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/b4c8eff1bb7a1e24.
Report an issue: GitHub.