microsoft/typescript-go · error

failed to flush trace file: %w

Error message

failed to flush trace file: %w

What it means

Error "failed to flush trace file: %w" thrown in microsoft/typescript-go.

Source

Thrown at internal/tracing/tracing.go:224

func (tr *Tracing) writeEvent(event traceEvent) {
	writeEventTo(&tr.traceContent, event)
}

// maybeFlushLocked appends the buffered trace content to disk if it has grown
// past the flush threshold. Caller must hold tr.mu. If a previous flush failed,
// or this flush fails, the error is recorded in tr.flushErr and subsequent
// writes become no-ops; the error is surfaced from StopTracing.
func (tr *Tracing) maybeFlushLocked() {
	if tr.flushErr != nil {
		tr.traceContent.Reset()
		return
	}
	if tr.traceContent.Len() < flushThreshold {
		return
	}
	if err := tr.fs.AppendFile(tr.tracePath, tr.traceContent.String()); err != nil {
		tr.flushErr = fmt.Errorf("failed to flush trace file: %w", err)
	}
	tr.traceContent.Reset()
}

// Instant records an instant event in the trace.
// Safe to call on nil receiver.
func (tr *Tracing) Instant(phase Phase, name string, args map[string]any) {
	if tr == nil || !tr.traceStarted.Load() {
		return
	}

	tr.mu.Lock()
	defer tr.mu.Unlock()

	// Re-check under the lock: StopTracing may have run between the load above
	// and acquiring the lock. Once stopped, further writes would land in a buffer
	// that has already been flushed and the closing "]" written.
	if !tr.traceStarted.Load() {

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/tracing/tracing.go:224 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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