{"record":{"id":"2151b88920a03140","repo":"microsoft/typescript-go","slug":"api-remote-error-d-s-2151b8","errorCode":null,"errorMessage":"api: remote error [%d]: %s","messagePattern":"api: remote error \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/conn_sync.go","lineNumber":194,"sourceCode":"\tid := jsonrpc.NewIDString(method)\n\n\tif err := c.protocol.WriteRequest(id, method, params); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif ctx.Err() != nil {\n\t\treturn nil, ctx.Err()\n\t}\n\n\t// Read the response inline.\n\tmsg, err := c.protocol.ReadMessage()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif msg.IsResponse() && msg.ID != nil && msg.ID.String() == method {\n\t\tif msg.Error != nil {\n\t\t\treturn nil, fmt.Errorf(\"api: remote error [%d]: %s\", msg.Error.Code, msg.Error.Message)\n\t\t}\n\t\treturn msg.Result, nil\n\t}\n\n\t// Unexpected message while waiting for response\n\treturn nil, fmt.Errorf(\"api: unexpected message while waiting for %q response\", method)\n}\n\n// Notify sends a notification to the client (no response expected).\nfunc (c *SyncConn) Notify(ctx context.Context, method string, params any) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.protocol.WriteNotification(method, params)\n}\n","sourceCodeStart":176,"sourceCodeEnd":209,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/conn_sync.go#L176-L209","documentation":"Returned (not panicked) by SyncConn.Call when the peer answered a server-to-client request with an error response. Under the msgpack protocol every remote failure is normalized to JSON-RPC code -32603 (internal error) with the peer's message text, so the printed message tells you what the client-side handler failed to do.","triggerScenarios":"The server issues a Call (e.g. a filesystem callback such as readFile/readDirectory) and the client's handler returns an error: the requested file no longer exists client-side, permissions fail, or the method is unimplemented.","commonSituations":"File deleted or renamed between the change notification and the callback; client running a virtual filesystem that rejects the path; permission errors on the client host; partially implemented client handlers.","solutions":["Read the message text - it is the error string from the peer's handler for the method you invoked","Reproduce the failing operation manually on the client (e.g. stat/read the exact path shown)","Fix the client handler (restore the file, fix permissions, implement the method) and retry the server call","If the file legitimately vanished, send a filesChanged/deleted notification so the server drops its cached state instead of calling for it"],"exampleFix":"// before (client): readFile handler errors because the file was deleted\n\n// after (client): notify the deletion first so the server invalidates state\nclient.Notify(\"filesChanged\", api.APIFileChangeSummary{\n\tDeleted: []api.DocumentIdentifier{{FileName: \"/abs/deleted.ts\"}},\n})","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := conn.Call(ctx, \"readFile\", params)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"api: remote error [\") {\n\t\t// the failure is on the peer's side; its message text says why\n\t\tlog.Printf(\"client handler failed: %v\", err)\n\t}\n\treturn res, err\n}","preventionTips":["Implement every callback method the server may Call (filesystem access especially)","Keep files the server knows about present, or notify deletions via filesChanged","Return descriptive errors from client handlers so the relayed message is actionable"],"tags":["go","jsonrpc","remote-error","filesystem","callback","client-handler"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}