@remotion/studio: Consolidate SSE connections to fix multi-tab hanging#6887
Conversation
There was a problem hiding this comment.
LGTM. The consolidation is straightforward and well-executed — HMR events now flow through the existing /events SSE connection instead of a separate endpoint, reducing per-tab connections from 2 to 1 and eliminating ~150 lines of redundant EventSource infrastructure. The publishHmr → sendEventToClient({type: 'hmr', ...}) → processHmrEvent → processMessage chain is correct and has no dead code or stale references.
|
Thanks, will look at it after #6826 is merged |
|
Sounds good, I'll rebase onto main once #6826 is merged. Let me know if you'd like any changes in the meantime. |
Route webpack HMR events through the existing `/events` SSE connection instead of maintaining a separate `/__webpack_hmr` endpoint. This reduces per-tab SSE connections from 2 to 1, preventing Chrome's HTTP/1.1 6-connection-per-origin limit from being hit with 3+ tabs. Closes remotion-dev#6863 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…date in production process-update.ts has a top-level `if (!__webpack_module__.hot) throw` guard that crashes when imported in production bundles (where HMR is disabled). Using a global callback registered by enableHotMiddleware() avoids this import chain in production. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f382fed to
f31a18a
Compare
|
conflicts resolved. but ci failed, I'm going to check soon. |
Lazy-compiled modules (enabled when running with Node.js) need HMR updates to deliver compiled code. The React-managed /events SSE (PreviewServerConnection) only connects after React mounts, which depends on registerRoot() — itself called from a lazy-compiled module. This chicken-and-egg problem prevented the studio from loading. Fix by creating a standalone /events SSE listener in enableHotMiddleware(), which runs synchronously before React mounts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thank you! |

Summary
/eventsSSE connection instead of a separate/__webpack_hmrendpointCloses #6863
Test plan
cd packages/example && bun run dev— start Studiolocalhost:3000— all should load without hanging/events) per tab, no/__webpack_hmr🤖 Generated with Claude Code