Next.js dev bundles server packages per route, so a module-level Set forks into one copy per bundle: a broadcast issued from a server action or registry bundle would never reach a client subscribed through the /api/realtime route bundle. Anchoring the client set on globalThis unifies every bundle copy within the single dev process, the same trick blackjack/poker already use. It is a no-op in production, which has one module instance anyway. |
||
|---|---|---|
| .. | ||
| bus.ts | ||
| presence.ts | ||