{"record":{"id":"118f7285ded27a03","repo":"microsoft/typescript-go","slug":"failed-to-write-trace-file-w","errorCode":null,"errorMessage":"failed to write trace file: %w","messagePattern":"failed to write trace file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tracing/tracing.go","lineNumber":460,"sourceCode":"\t\tif err := tracer.DumpTypes(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to dump types for checker %d: %w\", tracer.checkerIndex, err)\n\t\t}\n\t}\n\n\ttr.mu.Lock()\n\tdefer tr.mu.Unlock()\n\n\t// Close the trace file(s)\n\tif tr.traceStarted.Load() {\n\t\t// Surface any buffered flush failure before attempting the final write.\n\t\tif tr.flushErr != nil {\n\t\t\ttr.traceContent.Reset()\n\t\t\ttr.traceStarted.Store(false)\n\t\t\treturn tr.flushErr\n\t\t}\n\t\t// Flush any remaining buffered content and close the JSON array.\n\t\tif err := tr.fs.AppendFile(tr.tracePath, tr.traceContent.String()+\"\\n]\\n\"); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write trace file: %w\", err)\n\t\t}\n\t\ttr.traceContent.Reset()\n\t\ttr.traceStarted.Store(false)\n\t}\n\n\t// Sort legend entries by typesPath for deterministic output\n\tslices.SortFunc(tr.legend, func(a, b TraceRecord) int {\n\t\treturn strings.Compare(a.TypesPath, b.TypesPath)\n\t})\n\n\t// Write the legend file\n\tlegendPath := tspath.CombinePaths(tr.traceDir, \"legend.json\")\n\tlegendData, err := json.MarshalIndent(tr.legend, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal legend file: %w\", err)\n\t}\n\tif err := tr.fs.WriteFile(legendPath, string(legendData)); err != nil {\n\t\treturn fmt.Errorf(\"failed to write legend file: %w\", err)","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/tracing/tracing.go#L442-L478","documentation":"Error \"failed to write trace file: %w\" thrown in microsoft/typescript-go.","triggerScenarios":"Thrown at internal/tracing/tracing.go:460 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"}