-
-
Notifications
You must be signed in to change notification settings - Fork 972
fix(sdk): handle locked ReadableStream when retrying batch trigger #2917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d6d933d The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 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 |
WalkthroughThis pull request introduces a fix for a batch trigger failure in the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Detailed AnalysisScope of Changes:
Key Considerations for Review:
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (9)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{packages/core,apps/webapp}/**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{test,spec}.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.ts📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
Files:
**/*.{js,ts,jsx,tsx,json,md,yaml,yml}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.test.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.test.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{packages,integrations}/**/*📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📓 Common learnings⏰ 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). (23)
🔇 Additional comments (1)
✏️ Tip: You can disable this entire section by setting 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 |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
When fetch crashes mid-stream during batch item upload (e.g., connection reset, timeout), the request stream may remain locked by fetch's internal reader. Attempting to cancel a locked stream throws 'Invalid state: ReadableStream is locked', causing the batch operation to fail. Added safeStreamCancel() helper that gracefully handles locked streams by catching and ignoring the locked error. The stream will be cleaned up by garbage collection when fetch eventually releases the reader. Fixes customer issue where batchTrigger failed with ReadableStream locked error during network instability.
e770b4b to
d6d933d
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` ## [email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` - `@trigger.dev/[email protected]` - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Add support for AI SDK v6 (Vercel AI SDK) ([#2919](#2919)) - Updated peer dependency to allow `ai@^6.0.0` alongside v4 and v5 - Updated internal code to handle async validation from AI SDK v6's Schema type - Expose user-provided idempotency key and scope in task context. `ctx.run.idempotencyKey` now returns the original key passed to `idempotencyKeys.create()` instead of the hash, and `ctx.run.idempotencyKeyScope` shows the scope ("run", "attempt", or "global"). ([#2903](#2903)) - Fix batch trigger failing with "ReadableStream is locked" error when network failures occur mid-stream. Added safe stream cancellation that gracefully handles locked streams during retry attempts. ([#2917](#2917)) - Add a maxDepth to flatten/unflattenAttributes to prevent possible issues ([#2890](#2890)) ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` - `@trigger.dev/[email protected]` - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Updated dependencies: - `@trigger.dev/[email protected]` ## @trigger.dev/[email protected] ### Patch Changes - Add support for AI SDK v6 (Vercel AI SDK) ([#2919](#2919)) - Updated peer dependency to allow `ai@^6.0.0` alongside v4 and v5 - Updated internal code to handle async validation from AI SDK v6's Schema type - Expose user-provided idempotency key and scope in task context. `ctx.run.idempotencyKey` now returns the original key passed to `idempotencyKeys.create()` instead of the hash, and `ctx.run.idempotencyKeyScope` shows the scope ("run", "attempt", or "global"). ([#2903](#2903)) - Updated dependencies: - `@trigger.dev/[email protected]` --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
When fetch crashes mid-stream during batch item upload (e.g., connection
reset, timeout), the request stream may remain locked by fetch's
internal reader. Attempting to cancel a locked stream throws 'Invalid
state: ReadableStream is locked', causing the batch operation to fail.
Added safeStreamCancel() helper that gracefully handles locked streams
by catching and ignoring the locked error. The stream will be cleaned up
by garbage collection when fetch eventually releases the reader.
Fixes customer issue where batchTrigger failed with ReadableStream
locked error during network instability.