2.3 KiB
2.3 KiB
Realtime Streams Testing Guide
Overview
This app is set up to test Trigger.dev realtime streams with resume/reconnection functionality.
How It Works
1. Home Page (/)
- Displays buttons for different stream scenarios
- Each button triggers a server action that:
- Starts a new task run
- Redirects to
/runs/[runId]?accessToken=xxx
2. Run Page (/runs/[runId])
- Displays the live stream for a specific run
- Receives
runIdfrom URL path parameter - Receives
accessTokenfrom URL query parameter - Shows real-time streaming content using
useRealtimeRunWithStreams
Testing Resume/Reconnection
Test Scenario 1: Page Refresh
- Click any stream button (e.g., "Markdown Stream")
- Watch the stream start
- Refresh the page (Cmd/Ctrl + R)
- The stream should reconnect and continue from where it left off
Test Scenario 2: Network Interruption
- Start a long-running stream (e.g., "Stall Stream")
- Open DevTools → Network tab
- Throttle to "Offline" briefly
- Return to "Online"
- Stream should recover and resume
Test Scenario 3: URL Navigation
- Start a stream
- Copy the URL
- Open in a new tab
- Both tabs should show the same stream state
Available Stream Scenarios
- Markdown Stream: Fast streaming of formatted markdown (good for quick tests)
- Continuous Stream: 45 seconds of continuous word streaming
- Burst Stream: 10 bursts of rapid tokens with pauses
- Stall Stream: 3-minute test with long pauses (tests timeout handling)
- Slow Steady Stream: 5-minute slow stream (tests long connections)
What to Watch For
- Resume functionality: After refresh, does the stream continue or restart?
- No duplicate data: Reconnection should not repeat already-seen chunks
- Console logs: Check for
[MetadataStream]logs showing resume behavior - Run status: Status should update correctly (EXECUTING → COMPLETED)
- Token count: Final token count should be accurate (no missing chunks)
Debugging
Check browser console for:
[MetadataStream]logs showing HEAD requests and resume logic- Network requests to
/realtime/v1/streams/... - Any errors or warnings
Check server logs for:
- Stream ingestion logs
- Resume header values (
X-Resume-From-Chunk,X-Last-Chunk-Index)