Module: lib/core/trace/recorder

The trace recorder: a bounded buffer plus determinism bookkeeping.

The recorder owns everything a trace needs that the tracer hook surface deliberately does not: node ids, timestamps, the ring buffer, the redaction rules, the log of non-deterministic globals, and the running judgement of whether this session could be replayed.

That last part is the reason this class exists rather than an array. A trace that claims to be deterministic and is not produces a regression test that passes for the wrong reason, which is worse than no test. The recorder therefore downgrades eagerly and never upgrades.

Source:

Classes

TraceRecorder

Members

(static, constant) DEFAULT_MAX_NODES :number

How many nodes a recording keeps before it starts dropping the oldest.

A minute of interaction on a busy list produces a lot of nodes; an unbounded array would be a memory leak in a dev server that stays open all day. When the buffer wraps, the trace is marked truncated and therefore best-effort, because it no longer starts at the beginning of the session.

Type:
  • number
Source:

(static, constant) RecorderPhase :string

Where a recorder is in its lifecycle.

Writes during setup are the application constructing itself and are not evidence of non-determinism. Writes during recording with nothing on the causal stack are: something outside the recorded inputs changed state.

Type:
  • string
Source:

(inner, constant) SCRUB_MAX_DEPTH :number

How deep the serialization scrub walks a node.

Captured values are already bounded by captureValue, so this only has to match that ceiling.

Type:
  • number
Source:

Methods

(static) activeRecorder() → {TraceRecorder|null}

The recorder currently attached to the tracer, if any.

Source:
Returns:
Type
TraceRecorder | null

(static) startRecording(optionsopt) → {TraceRecorder}

Starts recording, replacing any recording already in progress.

Parameters:
Name Type Attributes Description
options object <optional>

Options forwarded to TraceRecorder.

Source:
Returns:

The active recorder.

Type
TraceRecorder

(static) stopRecording() → {object|null}

Stops the active recording.

Source:
Returns:

The finished trace, or null if nothing was recording.

Type
object | null

(inner) generateId() → {string}

Generates a short, readable trace id.

Source:
Returns:

An id such as trace-4f2a.

Type
string

(inner) now() → {number}

Reads a monotonic clock, falling back where performance is absent.

Source:
Returns:

Milliseconds from an arbitrary origin.

Type
number