The last question's answers can be lost when a quiz ends
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, postgresql, typescript
调研方向
Start with apps/ws-server/src/utils/answerQueue.ts, focusing on flushSession, drainSession, and the insert-then-score-update sequence. Trace the quiz:end and end-of-questions callers, then locate the existing answer-queue tests and add coverage for an in-flight flush. Done means all buffered answers are written before the leaderboard is read, and answer persistence plus score updates are atomic or fully retryable.
由索引模型根据 Issue 内容生成。
描述
Answers are buffered in apps/ws-server/src/utils/answerQueue.ts and written in batches. Two paths in that file can lose a batch.
1. drainSession does not actually wait for an in-flight flush
export async function flushSession(sessionId: string): Promise<void> {
if (flushing.has(sessionId)) return; // resolves immediately
...
}
export async function drainSession(sessionId: string): Promise<void> {
...
try {
await flushSession(sessionId); // a no-op if a flush is already running
} catch { }
...
buffers.delete(sessionId); // deletes answers regardless
}
If a flush is already running, await flushSession() returns straight away without waiting for it, and drainSession goes on to delete the buffer. Two losses follow:
- Answers that arrived during the in-flight write are still in
buffersand are deleted unwritten. - If that in-flight flush then fails, its
catchrequeues intobuffers.get(sessionId)— a map that was just deleted — so the requeue silently does nothing.
This fires on the hot path: drainSession runs at quiz:end and at end-of-questions, immediately after the final question closes, which is exactly when a flush is most likely to be in flight.
Impact: the final question's answers are missing from the leaderboard everyone finishes on, and there is no error anywhere.
2. A failed score update is never retried correctly
The flush inserts answers and then increments scores in two sequential awaits. If the insert succeeds and the score transaction fails, the whole batch is requeued — but on retry the rows already exist, skipDuplicates drops them all, and the returned set is empty. The score increments are skipped and never happen.
Result: ParticipantAnswer rows exist with the right points, while Participant.score was never incremented. The retry looks like a success. The leaderboard sorts on score, so the rankings stay wrong for the rest of the quiz.
What a fix looks like
- Have
flushSessionreturn the in-flight promise rather thanundefined, so callers can genuinely await it, and loop indrainSessionuntil the buffer is empty before deleting. - Make the insert and the score increments atomic, or derive
scorefromSUM(points)instead of incrementing — the data to reconcile is already inParticipantAnswer.points.
Definition of done
- Ending a quiz writes every buffered answer before the final leaderboard is read
- A failed flush either fully applies or fully retries; no state where answers exist but scores do not
- A test covering "flush in flight when the quiz ends"
- 主要语言
- TypeScript
- 星标
- 21
- 派生
- 7
- 平均合并
- 4 小时 13 分钟
- 30 天内合并 PR
- 20
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TheCodeHeist-Coder/Rexial 的其他 Issue
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
TheCodeHeist-Coder/Rexial#195 · 2 条评论 ·
维护者通常 1 天内回复
-
One PDF upload freezes the whole AI service, including its health check可能已有人在做 @Anshuu2004 今天认领。 未关闭Backend first issue bug help wanted
难度 2/5 1-3 小时 新手友好度 84/100
TheCodeHeist-Coder/Rexial#193 · 2 条评论 ·
维护者通常 1 天内回复
-
The join endpoint returns an error shape the frontend cannot read可能已有人在做 @Anshuu2004 今天认领。 未关闭Backend first issue bug good first issue help wanted
难度 2/5 1-3 小时 新手友好度 86/100
TheCodeHeist-Coder/Rexial#192 · 1 条评论 ·
维护者通常 1 天内回复
-
Registering without a password returns a 500 instead of telling you what is missing可能已有人在做 @Anshuu2004 于 1 天前认领。 未关闭Backend first issue bug good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
TheCodeHeist-Coder/Rexial#191 · 1 条评论 ·
维护者通常 1 天内回复
-
CI does not run the frontend tests可能已有人在做 @nayan45633 今天认领。 未关闭Backend first issue good first issue help wanted
难度 2/5 1-3 小时 新手友好度 76/100
TheCodeHeist-Coder/Rexial#188 · 2 条评论 ·
维护者通常 1 天内回复
查看 TheCodeHeist-Coder/Rexial 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
farion1231/cc-switch#8829 ·
维护者通常 1 天内回复
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutover未关闭doc-audit enhancement
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100