{"record":{"id":"d9a74a6fdb2f8274","repo":"microsoft/typescript-go","slug":"api-failed-to-write-reset-server-timing-response","errorCode":null,"errorMessage":"api: failed to write reset server timing response: %v","messagePattern":"api: failed to write reset server timing response: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/conn_sync.go","lineNumber":104,"sourceCode":"\t// to the handler, so they are answered directly and not themselves recorded.\n\tswitch msg.Method {\n\tcase string(MethodGetServerTiming):\n\t\tc.mu.Lock()\n\t\twriteErr := c.protocol.WriteResponse(msg.ID, serverTimingSnapshot(c.timing))\n\t\tc.mu.Unlock()\n\t\tif writeErr != nil {\n\t\t\tpanic(fmt.Sprintf(\"api: failed to write server timing response: %v\", writeErr))\n\t\t}\n\t\treturn\n\tcase string(MethodResetServerTiming):\n\t\tif c.timing != nil {\n\t\t\tc.timing.reset()\n\t\t}\n\t\tc.mu.Lock()\n\t\twriteErr := c.protocol.WriteResponse(msg.ID, nil)\n\t\tc.mu.Unlock()\n\t\tif writeErr != nil {\n\t\t\tpanic(fmt.Sprintf(\"api: failed to write reset server timing response: %v\", writeErr))\n\t\t}\n\t\treturn\n\t}\n\n\tvar result any\n\tvar err error\n\n\tstart := time.Time{}\n\tif c.timing != nil {\n\t\tstart = time.Now()\n\t}\n\n\t// Recover from panics and convert to error response with stack trace\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tstack := string(debug.Stack())\n\t\t\terr = fmt.Errorf(\"panic: %v\\n%s\", r, stack)\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/conn_sync.go#L86-L122","documentation":"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.","triggerScenarios":"Client sends resetServerTiming then closes the connection immediately; transport teardown racing the meta-request handler.","commonSituations":"Benchmark harnesses that reset timings at end-of-run and exit; clients with aggressive timeouts.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"_, err := conn.Call(ctx, \"resetServerTiming\", nil)\nif err != nil { /* connection torn down mid-reply: ensure orderly shutdown, then retry if needed */ }","preventionTips":["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"],"tags":["json-rpc","go","shutdown","transport"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}