fix: surface auth failures and fix reconnect resubscription (#45, #46)#47
Merged
anilcancakir merged 5 commits intomasterfrom Apr 7, 2026
Merged
fix: surface auth failures and fix reconnect resubscription (#45, #46)#47anilcancakir merged 5 commits intomasterfrom
anilcancakir merged 5 commits intomasterfrom
Conversation
Relative `sqlite3.wasm` URI resolved against the current page path when using path URL strategy, causing 404s on deep routes. Changed to absolute `/sqlite3.wasm` so the binary always loads from the web root.
…tion (#45) - Add `authFactory` constructor DI param to ReverbBroadcastDriver for testable auth (follows existing `channelFactory` pattern) - Replace bare `catch(_)` in `_authenticateAndSubscribe()` with error logging via `Log.error()` and interceptor chain routing - Await `_authenticateAndSubscribe()` in reconnect loop so `onReconnect` stream emits only after all resubscriptions complete - Per-channel try/catch in reconnect ensures one auth failure does not block other channels from resubscribing - Snapshot `_channels.keys.toList()` before iteration to prevent concurrent modification during reconnect - Add 5 new tests covering auth failure visibility, reconnect resubscription, onReconnect timing, and partial failure resilience
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… and #46 - Add [Unreleased] section to CHANGELOG.md with bug fix entries - Update broadcasting doc: auto-resubscription after reconnect, auth error logging behavior, onReconnect timing guarantee - Update skill reference: authFactory DI param, auth failure handling - Update .claude/rules/broadcasting.md: reconnect resubscription and auth error handling conventions
There was a problem hiding this comment.
Pull request overview
This PR fixes two web-related reliability issues in the Magic framework: correct loading of sqlite3.wasm under path-based routing, and making Reverb WebSocket reconnects reliably re-authenticate/re-subscribe channels while surfacing auth failures via logging and interceptors.
Changes:
- Load
sqlite3.wasmfrom an absolute/sqlite3.wasmURL on web to avoid route-relative 404s. - Add
authFactoryDI + improved error logging/interceptor routing for broadcasting channel auth, and await resubscriptions during reconnect before emittingonReconnect. - Add reconnect resubscription tests, including auth failure visibility and partial failure resilience.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/broadcasting/drivers/reverb_broadcast_driver_test.dart | Adds tests covering reconnect resubscription behavior and auth failure surfacing. |
| lib/src/database/connectors/connection_factory_web.dart | Switches WASM load URL to an absolute path to work with path URL strategy. |
| lib/src/broadcasting/drivers/reverb_broadcast_driver.dart | Introduces injectable auth, logs/auth error routing, and resubscribe-on-reconnect behavior changes. |
- Validate response type in _defaultAuthFactory instead of force-cast — returns empty map for non-Map responses so malformed auth hits the warning path instead of throwing a generic TypeError - Check _channels.containsKey(name) in reconnect loop to skip channels that were leave()'d after the snapshot was taken - Add interceptor after initial subscribe in test so assertion only captures reconnect-time auth errors, not the initial subscribe failure
…path Cover the Log.warning path triggered when auth response is missing the 'auth' key. Also verify that channels with malformed auth do not receive subscribe frames.
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.
Summary
/sqlite3.wasm.authFactoryconstructor DI param for testable authcatch(_)withLog.error()+ interceptor chain routing_authenticateAndSubscribe()in reconnect loop soonReconnectemits after completion_channels.keys.toList()to prevent concurrent modificationTest plan
flutter test)dart analyze— zero warningsCloses #45, closes #46