microsoft/typescript-go · error

-32603

-32603

Error message

panic: %v
%s

What it means

The async JSON-RPC connection recovered a panic inside a request handler and converted it to a JSON-RPC error response with code -32603 (internal error), embedding the panic value and full Go stack trace in the message. The client sees a remote internal error; the server keeps running.

Source

Thrown at internal/api/conn_async.go:142

		if writeErr != nil {
			panic(fmt.Sprintf("api: failed to write reset server timing response: %v", writeErr))
		}
		return
	}

	var result any
	var err error

	start := time.Time{}
	if c.timing != nil {
		start = time.Now()
	}

	// Recover from panics and convert to error response with stack trace
	defer func() {
		if r := recover(); r != nil {
			stack := string(debug.Stack())
			err = fmt.Errorf("panic: %v\n%s", r, stack)

			c.writeMu.Lock()
			writeErr := c.protocol.WriteError(msg.ID, &jsonrpc.ResponseError{
				Code:    jsonrpc.CodeInternalError,
				Message: err.Error(),
			})
			c.writeMu.Unlock()

			if writeErr != nil {
				panic(fmt.Sprintf("api: failed to write panic error response: %v (original panic: %v)", writeErr, r))
			}
		}
	}()

	result, err = c.handler.HandleRequest(ctx, msg.Method, msg.Params)

	if c.timing != nil {
		c.timing.record(msg.Method, time.Since(start))

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Read the embedded stack trace to find the faulting server code path and report/fix it
  2. Update the server binary — many such panics are fixed regressions
  3. Work around by not sending the parameter combination that triggers it
  4. Retry once in case of a transient race, then surface the error
Defensive patterns

Strategy: try-catch

Try / catch

result, err := conn.Call(ctx, method, params)
if err != nil && strings.Contains(err.Error(), "panic:") {
    // server-side panic: extract stack from message, report upstream, optionally retry once
}

Prevention

When it happens

Trigger: Any panic (nil deref, index out of range, failed invariant) in a method dispatched through AsyncConn's handler; bugs in server-side request processing rather than in the transport.

Common situations: Server crashes on malformed-but-parsed params, uninitialized optional state (e.g. nil timing/FS), or regressions in a method implementation after an upgrade.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/5ddcb6f42ed15686. Report an issue: GitHub.