fix(sdk): recover chat transport when a restored session no longer exists#3816
fix(sdk): recover chat transport when a restored session no longer exists#3816ericallam wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 652616d The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
🧰 Additional context used🧠 Learnings (11)📓 Common learnings📚 Learning: 2026-05-19T21:04:52.902ZApplied to files:
📚 Learning: 2026-05-17T08:08:20.822ZApplied to files:
📚 Learning: 2026-05-12T21:04:01.335ZApplied to files:
📚 Learning: 2026-06-01T15:50:19.116ZApplied to files:
📚 Learning: 2026-05-23T15:25:28.060ZApplied to files:
📚 Learning: 2026-03-06T14:44:55.489ZApplied to files:
📚 Learning: 2026-03-25T15:29:25.889ZApplied to files:
📚 Learning: 2026-05-18T14:20:00.606ZApplied to files:
📚 Learning: 2026-05-23T09:12:50.004ZApplied to files:
📚 Learning: 2026-06-02T21:20:48.907ZApplied to files:
🔇 Additional comments (1)
WalkthroughThis PR adds session recreation recovery to the chat transport. When a restored session references a session that no longer exists in the environment, the hook now detects the 404 error via a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ists When a chat's session state is restored from a different environment (or from before the sessions model), the cached token points at a session that doesn't exist there. The transport assumed it was live and never created a real one, so the next message 404'd and the chat could not send. callWithAuthRetry now treats a 404 from a session call as a missing session: after the existing 401/403 token refresh, it recreates the session via startSession, drops the stale resume cursor, and retries the send once.
c4ebc49 to
652616d
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/plugins
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
Summary
When a chat's restored session state points at a session that no longer exists in the current environment — for example a
sessionsentry that was persisted against a different trigger environment —useTriggerChatTransportassumed the session was live and never created a real one. The next message then failed with a 404 and the chat couldn't send.Fix
callWithAuthRetrynow treats a 404 from a session-PAT-authed call as "this session doesn't exist here". After the existing 401/403 token refresh, a 404 recreates the session viastartSession, drops the stalelastEventIdresume cursor (it pointed at another environment's stream), and retries the send once. WhenstartSessionisn't configured the transport throws a clear message instead of a bare 404.