fix: close sse stream on abort#1812
Conversation
|
@Divv1524 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
There was a problem hiding this comment.
Thanks for your first PR on DevTrack! 🎉
A maintainer will review it within 48 hours. While you wait:
- Make sure CI is passing (type-check + lint)
- Double-check the PR description is filled out and the issue is linked
- Feel free to ask questions in Discussions if you need help
If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors!
|
Please rebase on main to resolve conflicts. Run: git fetch origin && git rebase origin/main |
|
This PR has merge conflicts because the stream route was updated after you opened this PR. The abort-on-close logic from this PR was partially incorporated in main already. Please rebase on the latest main to bring in the remaining improvements (max-duration timeout, |
4fb6e5a to
fa62c76
Compare
7feb78e
into
Priyanshu-byte-coder:main
|
🎉 Merged! Thanks for contributing to DevTrack. If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers. Keep an eye on open issues for your next contribution! |
Summary
Fixed the SSE stream lifecycle in
/api/streamso server-side resources are cleaned up reliably when clients disconnect, streams are canceled, or connections become stale.Closes #1608
Type of Change
Changes Made
ReadableStreamcontroller on client abortcontroller.enqueue()handling to prevent writes to closed streamsHow to Test
Steps for the reviewer to verify this works:
npm run lintnpm run type-checknpm run buildvitest run test/sse-stream-route.test.tsScreenshots (if UI change)
N/A
Checklist
npm run lintpasses locallynpm run type-check)Accessibility Checklist
Additional Notes
Full
npm testwas also run. The focused SSE test suite passed, but the full suite currently has unrelated pre-existing failures outside this change.