microsoft/typescript-go · info
failed to refresh code lens: %w
Error message
failed to refresh code lens: %w
What it means
RefreshCodeLens (server.go:357-366): the client advertised codeLens refresh support, but the fire-and-forget workspace/codeLens/refresh request could not be queued to the outgoing writer. Identical failure mode to the inlay-hint refresh: local send failure only, never a client response error, because no response is awaited.
Source
Thrown at internal/lsp/server.go:363
func (s *Server) RefreshInlayHints(ctx context.Context) error {
if !s.clientCapabilities.Workspace.InlayHint.RefreshSupport {
return nil
}
if err := sendClientRequestFireAndForget(s, lsproto.WorkspaceInlayHintRefreshInfo, lsproto.NoParams{}); err != nil {
return fmt.Errorf("failed to refresh inlay hints: %w", err)
}
return nil
}
func (s *Server) RefreshCodeLens(ctx context.Context) error {
if !s.clientCapabilities.Workspace.CodeLens.RefreshSupport {
return nil
}
if err := sendClientRequestFireAndForget(s, lsproto.WorkspaceCodeLensRefreshInfo, lsproto.NoParams{}); err != nil {
return fmt.Errorf("failed to refresh code lens: %w", err)
}
return nil
}
// ProgressStart implements project.Client.
func (s *Server) ProgressStart(message *diagnostics.Message, args ...any) {
if s.projectProgress != nil {
s.projectProgress.start(message, args...)
}
}
// ProgressFinish implements project.Client.
func (s *Server) ProgressFinish(message *diagnostics.Message, args ...any) {
if s.projectProgress != nil {
s.projectProgress.finish(message, args...)
}
}
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Treat as advisory: log-and-continue; the client re-requests code lenses on next interaction.
- During teardown, filter these out when the server/context is shutting down.
- If persistent mid-session, investigate the underlying writer error that appears alongside it.
Example fix
// before
if err := client.RefreshCodeLens(ctx); err != nil { return fmt.Errorf("reload: %w", err) }
// after
if err := client.RefreshCodeLens(ctx); err != nil {
log.Printf("code lens refresh skipped: %v", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if clientCaps.Workspace.CodeLens.RefreshSupport && ctx.Err() == nil {
if err := client.RefreshCodeLens(ctx); err != nil {
log.Printf("code lens refresh skipped: %v", err)
}
} Type guard
func codeLensRefreshSafe(caps lsproto.ResolvedClientCapabilities, ctx context.Context) bool {
return caps.Workspace.CodeLens.RefreshSupport && ctx.Err() == nil
} Try / catch
if err := client.RefreshCodeLens(ctx); err != nil {
if ctx.Err() != nil {
return nil // teardown; ignore
}
log.Printf("code lens refresh skipped: %v", err)
} Prevention
- Treat code lens refresh as advisory UX, not a correctness step.
- Don't fire refreshes after shutdown starts.
- Investigate repeated send failures — they indicate a failed writer, which will break all outgoing traffic.
When it happens
Trigger: Outgoing queue closed, writer failed, or background context canceled while a project reload or config change triggers a code lens refresh; commonly interleaved with session close.
Common situations: Shutdown races; broken pipe after an editor crash; tests tearing down in-memory connections with pending refreshes.
Related errors
- failed to refresh diagnostics: %w
- failed to refresh inlay hints: %w
- Unexpected number of arguments.
- Invalid value for ${name}: ${value}
- forRelease requires setPrerelease unless nativePreviewReleas
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/ed778bcb87060c11.
Report an issue: GitHub.