{"record":{"id":"a110b117b0254d2c","repo":"microsoft/typescript-go","slug":"failed-to-flush-trace-file-w","errorCode":null,"errorMessage":"failed to flush trace file: %w","messagePattern":"failed to flush trace file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tracing/tracing.go","lineNumber":224,"sourceCode":"\nfunc (tr *Tracing) writeEvent(event traceEvent) {\n\twriteEventTo(&tr.traceContent, event)\n}\n\n// maybeFlushLocked appends the buffered trace content to disk if it has grown\n// past the flush threshold. Caller must hold tr.mu. If a previous flush failed,\n// or this flush fails, the error is recorded in tr.flushErr and subsequent\n// writes become no-ops; the error is surfaced from StopTracing.\nfunc (tr *Tracing) maybeFlushLocked() {\n\tif tr.flushErr != nil {\n\t\ttr.traceContent.Reset()\n\t\treturn\n\t}\n\tif tr.traceContent.Len() < flushThreshold {\n\t\treturn\n\t}\n\tif err := tr.fs.AppendFile(tr.tracePath, tr.traceContent.String()); err != nil {\n\t\ttr.flushErr = fmt.Errorf(\"failed to flush trace file: %w\", err)\n\t}\n\ttr.traceContent.Reset()\n}\n\n// Instant records an instant event in the trace.\n// Safe to call on nil receiver.\nfunc (tr *Tracing) Instant(phase Phase, name string, args map[string]any) {\n\tif tr == nil || !tr.traceStarted.Load() {\n\t\treturn\n\t}\n\n\ttr.mu.Lock()\n\tdefer tr.mu.Unlock()\n\n\t// Re-check under the lock: StopTracing may have run between the load above\n\t// and acquiring the lock. Once stopped, further writes would land in a buffer\n\t// that has already been flushed and the closing \"]\" written.\n\tif !tr.traceStarted.Load() {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/tracing/tracing.go#L206-L242","documentation":"Error \"failed to flush trace file: %w\" thrown in microsoft/typescript-go.","triggerScenarios":"Thrown at internal/tracing/tracing.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}