microsoft/typescript-go · error
api: failed to write reset server timing response: %v
Error message
api: failed to write reset server timing response: %v
What it means
Same failure mode as 97 but for the $/resetServerTiming meta-request: the response write failed and the server panics with the underlying write error. Indicates the peer vanished or the transport errored mid-reply.
Source
Thrown at internal/api/conn_sync.go:104
// to the handler, so they are answered directly and not themselves recorded.
switch msg.Method {
case string(MethodGetServerTiming):
c.mu.Lock()
writeErr := c.protocol.WriteResponse(msg.ID, serverTimingSnapshot(c.timing))
c.mu.Unlock()
if writeErr != nil {
panic(fmt.Sprintf("api: failed to write server timing response: %v", writeErr))
}
return
case string(MethodResetServerTiming):
if c.timing != nil {
c.timing.reset()
}
c.mu.Lock()
writeErr := c.protocol.WriteResponse(msg.ID, nil)
c.mu.Unlock()
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)
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Keep the connection open until the reset response arrives
- Drain in-flight requests during graceful shutdown before closing the socket
- Reproduce locally with a delayed close to confirm the race, then adjust client lifecycle
Defensive patterns
Strategy: try-catch
Try / catch
_, err := conn.Call(ctx, "resetServerTiming", nil)
if err != nil { /* connection torn down mid-reply: ensure orderly shutdown, then retry if needed */ } Prevention
- Reset timings while the connection is healthy, not during teardown
- Close connections only after the request loop exits
- In benchmarks, read responses before process exit
When it happens
Trigger: Client sends resetServerTiming then closes the connection immediately; transport teardown racing the meta-request handler.
Common situations: Benchmark harnesses that reset timings at end-of-run and exit; clients with aggressive timeouts.
Related errors
- api: failed to write server timing response: %v
- -32603
- api: remote error [%d]: %s
- api: unexpected response message in sync connection
- -32603
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/d9a74a6fdb2f8274.
Report an issue: GitHub.