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'sreverse_proxyalso streams by default. If your proxy or CDN ignores that header, turn buffering off for the route. In nginx, that isproxy_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
Secureset. - 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
OPTIONSresponse. See allow another origin. - A redirect. The client does not follow redirects, so a redirect looks like a network error. Set
baseUrlto the final URL. Watch for a missing or extra trailing slash. - The server is down or returns
5xxerrors. 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:
authorizereturnedundefined. Log the session and the run's tags insideauthorize.- The token expired and the client has no
refreshAccessToken. Add one. See refresh expired tokens. - The token is for another run, environment, or audience. Mint it with the same runtime and
audiencethat the handler uses. - The signing key changed. Keep the old key in
verifyKeysuntil its tokens expire. See rotate signing keys. - The stream is not in the grant. A grant with
streams: ['answer']denies every other stream name. - 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 devrunscontractDefaults.worker.devConcurrencyattempts at once by default, and other workers runcontractDefaults.worker.concurrency. Other runs wait their turn. Raise it withrunlane dev --concurrencyorrunlane work --concurrency, or the worker'sconcurrencyoption.
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 ownpartsfromattempts. 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 devfor that config, then retry in the same app process. No run was saved privately. - Tests have no dev. Select
createTestLane()and execute work withdrain()orexecuteNext().
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.