Troubleshooting
Tabs do not receive each other’s messages
Section titled “Tabs do not receive each other’s messages”- Same
sourceNamein two tabs. A tab ignores messages whosesourceequals its ownsourceName. Leave it unset (a unique one is generated) or keep it unique per tab. - Different origins. Ports count:
localhost:3000andlocalhost:5173are different origins. So arehttpandhttps. - Different channel names or namespaces. The resolved
channelName(returned by the hook) must match exactly. registeredTypesdropping your type. If you set it, every type you send must be listed.
State looks stale or duplicated
Section titled “State looks stale or duplicated”messagesis a log, not state. Derive current values from it or usekeepLatestMessage. See Messages and channels.keepLatestMessageholds one slot across all types. A"b"message replaces a prior"a". UseregisteredTypesor separate channels for latest-per-type.- Rebroadcast loop. Sending from a
useEffecton state you also set from incoming messages makes tabs ping-pong. Send from event handlers instead.
Expired messages never disappear
Section titled “Expired messages never disappear”cleanupDebounceMs longer than cleaningInterval restarts the debounce on every tick, so cleanup never runs. Keep the debounce below the interval.
Duplicate deliveries
Section titled “Duplicate deliveries”Deduplication blocks a repeated message ID for deduplicationTTL (5 minutes by default). It does not collapse identical payloads sent twice, and it does not stop rebroadcast loops.
Everything fails with an error
Section titled “Everything fails with an error”Check the error field: it is set when the browser lacks BroadcastChannel (very old browsers) or channel setup fails. Surface it in the UI during development instead of failing silently.
Weird characters in sourceName break sending
Section titled “Weird characters in sourceName break sending”Stick to Latin-1 characters (plain ASCII is safest) in sourceName. Emoji or non-Latin text there can currently throw while the message ID is generated.
