microsoft/typescript-go · error
api: remote error [%d]: %s
Error message
api: remote error [%d]: %s
What it means
AsyncConn.Call received a well-formed error response from the peer and wrapped it: the number is the JSON-RPC error code, the text the remote message. It is the generic surface for every server-returned error, not a distinct failure itself.
Source
Thrown at internal/api/conn_async.go:220
delete(c.pending, *id)
}
}()
// Send the request
c.writeMu.Lock()
err := c.protocol.WriteRequest(id, method, params)
c.writeMu.Unlock()
if err != nil {
return nil, err
}
select {
case <-ctx.Done():
return nil, ctx.Err()
case resp := <-responseChan:
if resp.Error != nil {
return nil, fmt.Errorf("api: remote error [%d]: %s", resp.Error.Code, resp.Error.Message)
}
return resp.Result, nil
}
}
// Notify sends a notification to the client (no response expected).
func (c *AsyncConn) Notify(ctx context.Context, method string, params any) error {
c.writeMu.Lock()
defer c.writeMu.Unlock()
return c.protocol.WriteNotification(method, params)
}
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Inspect the message text and code to identify the real cause — fix the request accordingly
- Verify method names/params against the API surface of the matching server version
- If the code indicates -32601/-32602, correct the method/params; for -32603 treat as server bug and update
- Wrap Call results and surface err.Error() to logs for diagnosis
Example fix
// before
result, err := conn.Call(ctx, "geterr", args)
if err != nil { panic(err) }
// after
result, err := conn.Call(ctx, "geterr", args)
if err != nil {
log.Printf("server rejected geterr: %v", err)
return diagnose(err) // map message/code to a user-facing cause
} Defensive patterns
Strategy: try-catch
Try / catch
result, err := conn.Call(ctx, method, params)
if err != nil {
var re = regexp.MustCompile(`remote error \[(\-?\d+)\]: (.*)`)
if m := re.FindStringSubmatch(err.Error()); m != nil {
code, _ := strconv.Atoi(m[1]); msg := m[2]
switch code {
case -32601: // unknown method
case -32602: // bad params
default: // domain/internal error
}
}
} Prevention
- Check method names/params against the server version actually deployed
- Parse the code out of the message before deciding retry vs fail
- Wrap every Call with structured logging of code+message
When it happens
Trigger: Calling any method the server rejects: unknown method, invalid params (e.g. missing required field), server-side internal errors, or cancellation surfaced as an error.
Common situations: Method name typos or version skew between client and server; sending params not matching the server's expected shape; legitimate domain errors (file not found, invalid arguments) reported through JSON-RPC.
Related errors
- Connection not established
- -32603
- api: unexpected response message in sync connection
- api: failed to write server timing response: %v
- api: failed to write reset server timing response: %v
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/252c05e03b68c101.
Report an issue: GitHub.