Skip to Content
Runlane
Realtime

The run object

Every run field the browser receives, the permission that unlocks it, and what is never sent.

The browser never gets the full stored run. It gets a short list of safe fields. Your grant decides which of those fields arrive.

In React

useRun returns the run as run. It is undefined until the first snapshot arrives.

const { run } = useRun<typeof writeAnswer>(runId)

run?.status // 'running'
run?.meta?.progress // 3
run?.output // { parts: 10 }, once the run succeeds
FieldWhat it holdsNeeds
idThe run IDStatus
environmentThe environment that owns the runStatus
taskIdThe task ID, such as 'answer.write'Status
statusThe current statusStatus
attemptsHow many attempts have startedStatus
eventSequenceA counter that goes up with each status or metadata changeStatus
versionThe code version that started the run, when knownStatus
metaMetadata saved with context.updateMeta()Status and Meta
outputThe final output, typed from the taskStatus and Output
failureWhy the run failed: name, code, message, and retryableStatus and Output

useRun needs Status. Without it, run stays undefined.

output is the value your task returned, before any output schema transforms. Streamed parts are separate. useRun does not receive stream data at all. To show stream text, use useRunStream.

Status values

StatusMeaningFinished?
scheduledWaiting for its start timeNo
queuedReady, waiting for a workerNo
runningAn attempt is runningNo
retryingAn attempt failed. A retry is waiting.No
releasedPaused by a wait, such as a sleep or signalNo
cancellation_requestedCancel was asked for. The attempt is stopping.No
succeededFinished with an outputYes
failedFinished with a failureYes
cancelledStopped by a cancelYes
expiredDid not start before its deadlineYes

Compare status with plain strings, such as run.status === 'succeeded'. TypeScript checks them, so a typo is an error. A failed run is still normal data. The reader does not report it as an error. Check run.status and run.failure instead.

Metadata

Each context.updateMeta() call sends a patch. The client merges it into run.meta:

  • A patch replaces the top-level keys it names. Other keys stay.
  • A nested object or array replaces the old value at that key. It does not merge.
  • null is a value. It does not delete the key.

Metadata from a task is typed as JSON. Check a value's type before you use it, or declare its type:

const progress = run?.meta?.progress
return <progress value={typeof progress === 'number' ? progress : 0} max={10} />

Never sent

These fields stay on the server, even when you grant every permission:

  • the task payload (its input);
  • tags, queue, priority, and keys;
  • failure stack traces and failure metadata;
  • wait tokens, leases, and trace data.

Keep secrets out of metadata and output anyway. A reader with Meta or Output sees everything in them.

In the plain client

client.subscribe() yields events instead of one merged object. A new reader gets a snapshot first, unless the run already finished. See follow a run for the order.

Event typeFields
snapshotrun: the fields above, plus createdAt, updatedAt, startedAt, and finishedAt as Date objects. Attempts are in run.counters.attempts.
statusstatus, attempts, eventSequence, version, and, with Output, output and failure
metaeventSequence, and patch: the top-level keys that changed
streamrecord: one stream record. See read a stream.

Every event also has cursor and occurredAt. See the JavaScript client for a full example.

On this page