Skip to Content
Runlane
Realtime

Troubleshooting

Fix buffered events, reconnect loops, denied access, and other realtime problems.

Find your symptom below. Each entry lists the usual causes and the fix.

Before you deploy

Check these before you put realtime behind a proxy or load balancer:

  • Buffering is off for the realtime route. The handler sends X-Accel-Buffering: no, and nginx follows it. Caddy's reverse_proxy also streams by default. If your proxy or CDN ignores that header, turn buffering off for the route. In nginx, that is proxy_buffering off;.
  • Idle timeouts are longer than contractDefaults.realtime.heartbeatInterval. The handler sends a small heartbeat at that interval to keep the connection alive.
  • Caching is off. The handler sends Cache-Control: no-store. Make sure your CDN respects it.
  • Your host streams responses and cancels the request when the browser disconnects. Serverless hosts that buffer whole responses do not work.
  • HTTPS is on. Session cookies also have Secure set.
  • CORS allows only your own origin, if you use another origin. See allow another origin.

Updates arrive in bursts, or only at the end

One-second bursts can come from polling: without a run signal, including when runHints: false, readers wait streams.pollInterval between reads. Its default is contractDefaults.streams.pollInterval (1s). Enable run hints on long-running hosts or lower streams.pollInterval to read more often.

A proxy or CDN may also buffer the response. It holds events until its buffer fills or the response ends.

Turn off buffering for the realtime route, as shown in before you deploy. To confirm, open the route with curl -N and check that events print one by one.

The connection closes every few minutes

This is normal. Each connection ends after contractDefaults.realtime.connectionDuration, or sooner if its token expires. The client reconnects right away and continues where it stopped. You do not need to do anything.

If it closes after only a few seconds, a proxy's idle timeout is shorter than contractDefaults.realtime.heartbeatInterval. Make the timeout longer.

The reader keeps reconnecting

onConnectionChange reports reconnecting with a growing attempt number. By default, retries continue until you abort the reader. Set reconnect.maxRetries in the client options to a non-negative number to stop after that many retries; 'unlimited' keeps retrying. contractDefaults.realtime.reconnect owns the default policy. Authentication and other permanent errors still stop immediately.

Common causes:

  • CORS. The browser hides CORS errors and shows a plain network error. Check the browser console and the OPTIONS response. See allow another origin.
  • A redirect. The client does not follow redirects, so a redirect looks like a network error. Set baseUrl to the final URL. Watch for a missing or extra trailing slash.
  • The server is down or returns 5xx errors. Check your server logs.

wire_invalid right away

The response did not come from the realtime handler, so the client could not read it. It does not retry this error.

Usually baseUrl points to the wrong path. Your framework then answers with its own HTML page, such as a 404. Check that baseUrl matches the path where you mounted the handler. To test it, open <baseUrl>/runs/<run-id>/events in a browser while signed in. You should get event data or a short JSON error, not an HTML page.

access_denied

The server returned 403. Check these in order:

  1. authorize returned undefined. Log the session and the run's tags inside authorize.
  2. The token expired and the client has no refreshAccessToken. Add one. See refresh expired tokens.
  3. The token is for another run, environment, or audience. Mint it with the same runtime and audience that the handler uses.
  4. The signing key changed. Keep the old key in verifyKeys until its tokens expire. See rotate signing keys.
  5. The stream is not in the grant. A grant with streams: ['answer'] denies every other stream name.
  6. Cookies on another origin. Browsers do not send cookies to another origin by default. Use tokens instead.

run_not_found

The handler could not find the run. Either the run was pruned, or the handler's runtime uses a different environment from the one that created the run. Use the same runtime setup in the app that starts runs and the app that serves realtime.

The run stays queued

No worker has picked up the run.

  • In development, check that dev's worker has the task registered and uses the same queue and environment. A trigger without dev fails; it cannot leave a queued run in app memory. See run local development.
  • In production, check that a worker is running and polls the run's queue.
  • No running worker has the task. Workers skip runs for tasks they don't have and log worker_task_missing. Deploy a worker that has the task. See change tasks safely.
  • All worker slots are busy. runlane dev runs contractDefaults.worker.devConcurrency attempts at once by default, and other workers run contractDefaults.worker.concurrency. Other runs wait their turn. Raise it with runlane dev --concurrency or runlane work --concurrency, or the worker's concurrency option.

Text repeats, or two answers run together

The page is joining parts from more than one attempt. Each retry starts a new attempt with its own parts.

  • React: use the default RunStreamMode.Latest, or read each attempt's own parts from attempts. Do not join every attempt's parts together.
  • Plain client: clear your text when a record has type: 'attempt_started'.

See retries and attempts.

The start of the text is missing

The stream has more parts than maxParts, so the hook dropped the oldest ones. truncated is true when this happens. Raise maxParts, or show a note when truncated is set. See long streams.

Rows in a long list stop updating

Each hook opens its own connection. Over HTTP/1.1, browsers allow only about six open connections to one origin, so later rows wait. See MDN's note on this limit.

Serve your app over HTTP/2. Most hosts and CDNs use it with HTTPS. Otherwise, show live updates for fewer rows at once.

storage_unavailable in development

The app cannot reach the runlane dev process.

  • Dev stopped. Start it again. Runs from before the restart are gone.
  • Dev is absent. The first trigger fails and names the config path. Start runlane dev for that config, then retry in the same app process. No run was saved privately.
  • Tests have no dev. Select createTestLane() and execute work with drain() or executeNext().

A hook throws configuration_invalid during render

The component has no RunlaneProvider above it, and you did not pass a client option. Wrap it in a provider.

The page is empty during server rendering

This is expected. The hooks return empty data on the server and start reading in the browser.

On this page