Repository navigation
fix(app): 點推播喚醒的事件在沒人訂閱時被丟掉——冷啟動補送(第十二輪) - #79
Merged
Merged
Conversation
FirebaseFleetPushService 用 StreamController.broadcast(),而廣播串流在沒有訂閱者的
當下 add 的事件會直接消失(Dart 不緩衝)。冷啟動的順序正好是這樣:
main() → createXxxPushService() → initialize() → getInitialMessage() → _events.add(事件)
→ runApp() → Controller.init() → ... → rideEvents.listen(...)
getInitialMessage() 是「App 被殺 → 點通知 → 冷啟動」唯一的取得管道,
而它在 runApp 之前就送出去了。於是司機端「被殺 → 點推播 → 接單卡」(A2 的招牌情境)
與乘客端「點推播 → 跟後端對帳」(第十一輪剛接好的)兩條都是死路徑——
兩端寫好的處理都在,缺的是事件本身。
改法:新增 PendingReplaySink,沒有訂閱者時留著**最後一則**,第一個訂閱者上來時
用 microtask 補送(onListen 在訂閱建立過程中被呼叫,當下同步 add 不保證送得到)。
補送過就丟掉,登出後重新訂閱不會再收到同一則。
驗收:flutter analyze 無 issue、flutter test 317 passed(312+新 5)。
反向確認:把 add 退回普通廣播行為,3 案 FAIL。
真裝置端到端仍卡 google-services.json(同 A2)——這批修的是純 Dart 串流語意,不需憑證。
文件:TODO 第十二輪專段、README 回填後端送出路徑已補(dispatch #61)與測試數 317。
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
根因(一句話)
FirebaseFleetPushService用StreamController.broadcast(),而廣播串流在沒有訂閱者的當下
add的事件會直接消失(Dart 不緩衝)。冷啟動的順序正好是這樣:getInitialMessage()是「App 被殺 → 點通知 → 冷啟動」唯一的取得管道,而它在
runApp之前就把事件送出去了。於是:兩端寫好的處理都在,缺的是事件本身。同一個形狀在本專案出現過很多次
(「處理寫好了,訊號從沒到達」),差別是這次的斷點在 App 自己的串流層,不是跨端契約。
改法
新增
PendingReplaySink<T>:沒有訂閱者時把事件留著,第一個訂閱者上來時用 microtask 補送(
onListen在訂閱建立過程中被呼叫,當下同步add不保證送得到那位訂閱者)。FirebaseFleetPushService._events換成它,其餘不動。只會讓畫面閃過一連串過期狀態。
驗收
flutter analyze無 issue、flutter test317 passed(312 +新 5)。add退回普通廣播行為(直接_controller.add),3 案 FAIL。google-services.json)。這批修的是「事件到不到得了訂閱者」,純 Dart 串流語意,不需要 Firebase 就能釘住。
同批的文件與維護
(dispatch PR #61)——
整條鏈路現在只剩 Firebase 憑證。
(判定用兩點 diff,squash 合併下
git branch --merged全漏)。xcrun devicectl無裝置。🤖 Generated with Claude Code