-
Notifications
You must be signed in to change notification settings - Fork 44
fix(cloudflare-workers): fix aborting sse streams #1280
fix(cloudflare-workers): fix aborting sse streams #1280
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @NathanFlurry's task —— View job PR Review: Fix Aborting SSE StreamsReview Checklist
SummaryThis PR fixes a critical issue with aborting SSE (Server-Sent Events) streams in Cloudflare Workers. The main changes focus on properly handling SSE stream lifecycle, implementing ping mechanisms for connection liveness detection, and improving cleanup procedures. Code Quality & Best Practices✅ Good
🔍 Areas for ImprovementDebug Logging in Production CodeFile: console.log("=== stream open ===");
console.log("=== stream error ===");Issue: Direct actor.rLog.debug("sse stream opened");
// or in error handler:
loggerWithoutContext().error({ msg: "sse stream error", error: err });Commented Dead CodeFile: // // HACK: Will throw if not configured
// try {
// c.executionCtx.waitUntil(abortResolver.promise);
// } catch {}Issue: Remove commented code or provide clear documentation about why it's commented out. Bug Analysis✅ Fixes Implemented
🚨 Potential IssuesPing Event FilteringFile: // Ignore pings
if (ev.type === "ping") return;Issue: This checks if (ev.event === "ping") return;Infinite Loop RiskFile: while (true) {
if (stream.closed || stream.aborted) {
// break;
}
await stream.writeSSE({ event: "ping", data: "" });
await stream.sleep(SSE_PING_INTERVAL);
}Issue: If while (true) {
if (stream.closed || stream.aborted) break;
try {
await stream.writeSSE({ event: "ping", data: "" });
await stream.sleep(SSE_PING_INTERVAL);
} catch (error) {
actor?.rLog.warn({ msg: "ping failed, stream likely closed", error });
break;
}
}Performance Considerations✅ Good
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
More templates
@rivetkit/actor
@rivetkit/cloudflare-workers
@rivetkit/core
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
commit: |
Merge activity
|

No description provided.