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

  1. Keep the connection open until the reset response arrives
  2. Drain in-flight requests during graceful shutdown before closing the socket
  3. 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

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


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