Skip to content

@remotion/studio: Consolidate SSE connections to fix multi-tab hanging#6887

Merged
JonnyBurger merged 4 commits intoremotion-dev:mainfrom
bskang-v6x:fix/consolidate-studio-sse-connections
Mar 25, 2026
Merged

@remotion/studio: Consolidate SSE connections to fix multi-tab hanging#6887
JonnyBurger merged 4 commits intoremotion-dev:mainfrom
bskang-v6x:fix/consolidate-studio-sse-connections

Conversation

@bskang-v6x
Copy link
Copy Markdown
Contributor

@bskang-v6x bskang-v6x commented Mar 20, 2026

Summary

  • Route webpack HMR events through the existing /events SSE connection instead of a separate /__webpack_hmr endpoint
  • 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+ Studio tabs open
  • Net reduction of ~150 lines by removing the standalone HMR event stream infrastructure

Closes #6863

Test plan

  • cd packages/example && bun run dev — start Studio
  • Open 3+ tabs on localhost:3000 — all should load without hanging
  • Edit a source file → verify HMR updates appear in all tabs
  • Check browser DevTools Network tab → confirm only 1 SSE connection (/events) per tab, no /__webpack_hmr

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Mar 25, 2026 0:56am
remotion Ready Ready Preview, Comment Mar 25, 2026 0:56am

Request Review

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 publishHmrsendEventToClient({type: 'hmr', ...})processHmrEventprocessMessage chain is correct and has no dead code or stale references.

Pullfrog  | View workflow runpullfrog.com𝕏

@JonnyBurger
Copy link
Copy Markdown
Member

Thanks, will look at it after #6826 is merged

@bskang-v6x
Copy link
Copy Markdown
Contributor Author

Sounds good, I'll rebase onto main once #6826 is merged. Let me know if you'd like any changes in the meantime.

bskang-v6x and others added 3 commits March 25, 2026 18:16
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>
@bskang-v6x
Copy link
Copy Markdown
Contributor Author

bskang-v6x commented Mar 25, 2026

@JonnyBurger

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>
@JonnyBurger
Copy link
Copy Markdown
Member

Thank you!
Had to let Claude run over it to actually make it work, but other than that, nice!

@JonnyBurger JonnyBurger merged commit a0d2396 into remotion-dev:main Mar 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: 2 tabs hit Chrome's 6-connection-per-origin limit

2 participants