{"record":{"id":"b4929cfa0baf2f43","repo":"microsoft/typescript-go","slug":"request-failed-s","errorCode":null,"errorMessage":"request failed: %s","messagePattern":"request failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lsp/server.go","lineNumber":683,"sourceCode":"\tdefer func() {\n\t\ts.pendingServerRequestsMu.Lock()\n\t\tdefer s.pendingServerRequestsMu.Unlock()\n\t\tif respChan, ok := s.pendingServerRequests[*id]; ok {\n\t\t\tclose(respChan)\n\t\t\tdelete(s.pendingServerRequests, *id)\n\t\t}\n\t}()\n\n\tif err := s.send(req.Message()); err != nil {\n\t\treturn *new(Resp), err\n\t}\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn *new(Resp), ctx.Err()\n\tcase resp := <-responseChan:\n\t\tif resp.Error != nil {\n\t\t\treturn *new(Resp), fmt.Errorf(\"request failed: %s\", resp.Error.String())\n\t\t}\n\t\treturn info.UnmarshalResult(resp.Result)\n\t}\n}\n\n// sendClientRequestFireAndForget sends a request to the client without waiting for a response.\n// The response, if any, will be silently ignored by the read loop since no pending channel is registered.\n// This means any error returned by the client will not be observed. Use only for requests where the\n// response value is not needed (e.g., the client always returns null).\nfunc sendClientRequestFireAndForget[Req, Resp any](s *Server, info lsproto.RequestInfo[Req, Resp], params Req) error {\n\tid := jsonrpc.NewIDString(fmt.Sprintf(\"ts%d\", s.clientSeq.Add(1)))\n\treq := info.NewRequestMessage(id, params)\n\treturn s.send(req.Message())\n}\n\nfunc (s *Server) sendResult(id *jsonrpc.ID, result any) error {\n\treturn s.sendResponse(&lsproto.ResponseMessage{\n\t\tID:     id,","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/lsp/server.go#L665-L701","documentation":"Returned by sendClientRequest when a server-to-client request (e.g. workspace/configuration, client/registerCapability, window/workDoneProgress/create) completes and the client replied with a JSON-RPC error response instead of a result. The %s is resp.Error.String(), so the client's own code and message are embedded. It is a normal protocol-level failure: the request was delivered, the client just refused or failed it.","triggerScenarios":"Calling a client capability the client never declared (e.g. sending workspace/configuration to a client without configuration support); client-side handler throws (ServerNotInitialized, InvalidParams from the client); client returns MethodNotFound for an optional request; user closes a progress dialog the server tried to create.","commonSituations":"Server assumes a capability from initializeOptions that the editor did not advertise; older editor version lacking a newer LSP method; VS Code rejecting window/workDoneProgress/create after the item was already disposed.","solutions":["Read the embedded client error text; it names the client's code (e.g. MethodNotFound, InvalidParams) which pinpoints the cause","Gate server-to-client requests on the capabilities returned in initialize before calling them","For optional integrations (telemetry, progress), treat this error as non-fatal and degrade gracefully","Upgrade the client/editor if the method requires a newer LSP revision"],"exampleFix":"// before\nresp, err := sendClientRequest(ctx, s, lsproto.WorkspaceConfigurationInfo, params)\nif err != nil {\n\treturn zero, err\n}\n\n// after - only request configuration when the client supports it\nif s.clientCapabilities().Workspace?.Configuration == true {\n\tresp, err = sendClientRequest(ctx, s, lsproto.WorkspaceConfigurationInfo, params)\n}","handlingStrategy":"validation","validationCode":"// before sending any server->client request, check the capability\ncaps := s.clientCapabilities()\nok := caps.Workspace != nil && caps.Workspace.Configuration != nil && *caps.Workspace.Configuration\nif !ok {\n\treturn defaults, nil // skip the request entirely\n}","typeGuard":"func canRequestConfiguration(caps *lsproto.ClientCapabilities) bool {\n\treturn caps.Workspace != nil &&\n\t\tcaps.Workspace.Configuration != nil &&\n\t\t*caps.Workspace.Configuration\n}","tryCatchPattern":"resp, err := sendClientRequest(ctx, s, info, params)\nif err != nil {\n\tif strings.Contains(err.Error(), \"request failed\") {\n\t\t// client refused; degrade to default behavior rather than failing the handler\n\t\treturn defaultValue, nil\n\t}\n\treturn zero, err\n}","preventionTips":["Gate every server-to-client request on advertised client capabilities from initialize","Parse the embedded client error code to distinguish MethodNotFound (unsupported) from real failures","Make optional client integrations non-fatal"],"tags":["jsonrpc","client-capabilities","lsp"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}