Repository navigation
修正:投票投影片端斷線後重送目前這頁的開題/離開狀態 - #6
Conversation
控制請求逾時後以退避(上限 15 秒、最多 8 次)重送目前這頁的狀態, online 事件或 WebSocket 重連時立即重送;換頁即作廢舊重送,揭曉/清空不重送。 另以 navDone 追蹤後端已確認的換頁,修正斷線時連過兩張非投票頁、後端停在上一題。 重新 build docs/index.html。
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c383a20455
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| clearTimeout(navTimer); navWait = seq; navBad = true; | ||
| if (navTry < 8) navTimer = setTimeout(() => navResend(seq), Math.min(15000, 1000 * 2 ** navTry++)); |
There was a problem hiding this comment.
Reset the retry budget when the slide changes
When an outage consumes retries on one slide and the presenter then navigates, navTry retains the previous slide's count because it is reset only after success or an online/WebSocket-open event. If it has already reached 8, the new slide's first failed request sets navWait but schedules no retry here; when the browser remains online and the existing WebSocket stays open (for example, a transient HTTP/control-path failure), recovery emits neither event, so the backend can remain on the old poll indefinitely. Reset the counter when starting a new navigation sequence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已在 615fa50 修正:onShow 每次換頁都會把 navTry 歸零,所以每一頁各有 8 次重送額度。已用 Playwright 驗證:WebSocket 一直開著、瀏覽器也在線,只有 /api/control 回 500。先在 warmup 用完 8 次重送,再換到非投票頁。修正前,{poll:null} 失敗 1 次之後就不再送,後端停在舊題;修正後會持續退避重送,控制路徑恢復後就送成功,後端 active=null。
上一頁斷線用完 8 次後換頁,新頁失敗不會再排重送;在網路與 WebSocket 都正常、 只有控制路徑失敗時,後端可能一直停在舊題。改在 onShow 重設 navTry。
補上 #5 留下的缺口:斷線超過 5 秒時,開題/離開的
/api/control會逾時,之後沒有任何重送,所以網路恢復後,後端(和觀眾手機)可能還停在舊的題目,或根本沒開題。修改內容(只動
screen/live-poll.js,docs/index.html重新 build)navFail)後,依 1、2、4、8 秒退避重送,上限 15 秒、最多 8 次(約 75 秒),不會密集重試。重送時讀的是當下這一頁的狀態:投票頁就重跑enterPoll(先查結果,已揭曉的題就送revealed),非投票頁就送{poll:null}。online事件或螢幕端 WebSocket 重新連上時,如果有待重送的狀態就馬上送出,不必等退避;8 次用完之後,網路恢復也會再送一次。navSeq,講者換頁後舊的重送就作廢,由新的那頁自己送。navDone記錄後端最後確認的換頁序號。原本斷線時連過兩張非投票頁,第一張的「離開」排隊時被當成過期略過,第二張又因為current已經是 null 而不送,後端就一直停在上一題。現在只要上一頁的狀態還沒確認,非投票頁也會送出「離開」。?offline/QA(webdriver)模式不排重送,畫面訊息和原本一樣。驗證(本機)
node --check、demo 模擬模式/不含 key 檢查、polls.json、py_compile、bash -n、ruff check都通過node --test test/stats.test.js:3 項通過npm run qa(離線模式 QA):12 頁通過,沒有溢出、沒有 JS 錯誤,QR 全部相符/api/control在斷線期間不回應(客戶端 5 秒逾時),表格列出後端實際收到的請求:warmup open、size open,最後後端active=null,沒有開題size open成功,後端active="size";過期的warmup/null沒有補送{poll:null}逾時後就沒有下文{poll:null}成功active="warmup"{poll:null}成功,後端active=nullonline事件){poll:null}請審閱,不要自動合併。