-
Notifications
You must be signed in to change notification settings - Fork 6
Implement listener registry pattern for HMR support #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+182
−65
Conversation
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
Separates "login once" from "bind listeners" logic to enable proper hot module reloading. Previously, the gateway flag prevented duplicate logins but also prevented listener code from being updated on HMR. Key changes: - Add listenerRegistry.ts with registerListener/removeAllListeners - Add HMR state helpers to client.server.ts (isClientReady, clearScheduledTasks) - Modify schedule.ts to return timer handles for cleanup - Refactor gateway.ts to split login from listener binding - Update all listener modules to use registerListener On HMR, old listeners are removed before rebinding new ones with fresh closures. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Preview environment removedThe preview for this PR has been cleaned up. |
✅ E2E Tests PassedTested against: https://250.euno-staging.reactiflux.com |
Move all HMR-related globals from scattered locations into a single hmrRegistry.ts module: - Login state (isLoginStarted/markLoginStarted) from gateway.ts - Client ready state (isClientReady/setClientReady) from client.server.ts - Scheduled tasks (registerScheduledTask/clearScheduledTasks) from client.server.ts - Listener registry (existing, renamed from listenerRegistry.ts) This centralizes HMR concerns and simplifies client.server.ts to just client instantiation and login. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace explicit registerListener() wrapper with a monkeypatch on client.on that automatically tracks listeners for HMR cleanup. This prevents future errors when someone uses client.on directly. - Patch client.on immediately after client creation - Remove registerListener/getListenerCount exports from hmrRegistry - Revert all 9 listener files to use native client.on syntax - Keep once() unpatched for one-time init handlers Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Separates "login once" from "bind listeners" logic to enable proper hot module reloading. Previously, the gateway flag prevented duplicate logins but also prevented listener code from being updated on HMR.
Key changes:
On HMR, old listeners are removed before rebinding new ones with fresh closures.