#7767 Server Sent Events (SSE) causes Error: The script will never generate a response
Valid bug: SSE using EventEmitter works in Node but fails in workerd with I/O context error. No reproduction provided but detailed code samples. 5 emoji reactions. Likely workerd I/O context limitation.
Keep open for workerd team investigation; suggest TransformStream workaround
Analysis Report
Issue Review: cloudflare/workers-sdk#7767
Summary
Server Sent Events (SSE) using EventEmitter in Remix/React Router v7 fail with "The script will never generate a response" error in workerd/wrangler dev.
Findings
- Created: 2025-01-14
- Updated: 2025-10-30
- Version: wrangler 3.99.0, miniflare 3.20241218.0 -> wrangler 4.60.0
- Component: Wrangler, Miniflare, Pages
- Labels: bug
- Comments: 0
Key Evidence
- Issue involves SSE implementation using node:events EventEmitter with remix-utils
- Works perfectly under Node.js (
react-router dev) but fails under workerd (wrangler pages dev) - Error: "A hanging Promise was canceled" and "The script will never generate a response"
- This appears to be a workerd runtime limitation - EventEmitter callbacks creating asynchronous events outside the request context are not properly tracked
- No reproduction provided but detailed code samples included
- No PRs found referencing this issue
- Not mentioned in any changelog
- Related to how workerd handles I/O context and promise resolution for long-lived connections
Recommendation
Status: KEEP OPEN
Reasoning: This is a valid bug affecting SSE implementations that rely on EventEmitter patterns. The error indicates workerd's I/O context handling doesn't properly support asynchronous event patterns used by SSE. The issue has 5 emoji reactions indicating user interest. This is likely a workerd-level limitation that needs investigation.
Action: Keep open for workerd team investigation. May require changes to how I/O contexts handle EventEmitter-triggered async operations. Consider linking to any related workerd issues about I/O context handling.
Suggested Comment
This issue appears to be related to how workerd handles I/O contexts for long-lived SSE connections using EventEmitter. The EventEmitter callbacks create async events outside the original request context, which workerd cannot track as belonging to the response.
Workaround: Consider using TransformStream approach instead of EventEmitter, as suggested in this Cloudflare community thread.
Keeping this open for investigation. Are you still experiencing this issue with the latest wrangler version (4.60.0)?
Notes & Feedback (0)
No notes yet.