Fix stale-cache asset loading; add broker connection watchdog#3
Merged
Conversation
Versions the style.css/app.js/peerjs script references with ?v= query strings so a browser can't run a cached old script against fresh HTML (which made the easy-mode code show a permanent '…' and a dead Copy button). Also adds a 15s watchdog on the signaling broker so a genuine stall shows an error and points to manual mode instead of hanging.
PeerJS 1.5 registers serializers raw/json/binary/binary-utf8 but no 'none' (it exists only as an enum value), so peer.connect with serialization:'none' threw 'this._serializers[t.serialization] is not a constructor'. 'raw' passes strings and binary through untouched, matching our own chunking and the string-vs-ArrayBuffer handling in onMessage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
After #2 merged, creating a connection showed a permanent
…instead of a word code, and the "Copy code" button did nothing — with no console errors.Root cause: a stale browser cache. The browser loaded the new
index.html(easy mode) but kept running a cachedapp.jsfrom #1 (manual-only). That old script set the status to "Generating invite…" / "Waiting for reply code", never touched#my-code(so it stayed at the static…), and had no handler for the new Copy button — and ran without errors because it only knew about the old elements. The deployedapp.jswas correct all along.The fix
?v=query strings (style.css?v=3,app.js?v=3,vendor/peerjs.min.js?v=1.5.4). When the HTML updates, the new URLs force a fresh fetch of the scripts, so a browser can't pair fresh HTML with a stale script again. (Bump the number on future asset changes — noted in an HTML comment.)…. Cleared on connect, on error, and on cancel/disconnect.Note for existing users
Anyone who already loaded the old version may need one hard refresh (Cmd/Ctrl+Shift+R) to pick up the versioned URLs; after that, cache-busting handles future updates automatically.
https://claude.ai/code/session_01BkoDW5wUsLsAtTse9djhki
Generated by Claude Code