Skip to content

api events

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Events

k6 runtime events carry live process output, live metrics, terminal completion, and execution errors from Rust to React. Event names are defined in both src/lib/loadrift/api.ts and src-tauri/src/events.rs.

Event Payload Description
k6:output string Streams k6 stdout, stderr, and runtime messages to the frontend log
k6:metrics RunMetricsEvent Emits initial and live metrics for a run
k6:complete TestCompletion Emits final state, finish reason, metrics, result, result source, summary issue, and optional error
k6:error RunErrorEvent Emits non-threshold execution errors

Run scoping

src/features/test/useTestHarness.ts filters metrics and completion by active run ID. That prevents stale events from previous runs from replacing the current UI state.

Completion versus error

Threshold failures complete through k6:complete with a failed result. Execution errors can also emit k6:error after completion state is recorded in src-tauri/src/k6/process/runtime.rs.

Key source files

File Purpose
src/lib/loadrift/api.ts Event constants and subscription signatures
src/lib/loadrift/types.ts Event payload types
src/lib/tauri/client.ts Window-scoped event listeners
src-tauri/src/events.rs Event emitters
src/features/test/useTestHarness.ts Frontend event handling

For the command side of the API, see Tauri commands.

Clone this wiki locally