The last question's answers can be lost when a quiz ends
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, postgresql, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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"
- Lingua principale
- TypeScript
- Stelle
- 21
- Fork
- 7
- Merge medio
- 4h 31m
- PR unite (30g)
- 22
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TheCodeHeist-Coder/Rexial
-
bug good first issue help wanted UI & UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TheCodeHeist-Coder/Rexial#205 ·
I maintainer di solito rispondono entro 1 giorno
-
One PDF upload freezes the whole AI service, including its health checkForse già presa @Anshuu2004 l’ha presa 1 giorno fa. ApertaBackend first issue bug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TheCodeHeist-Coder/Rexial#193 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The join endpoint returns an error shape the frontend cannot readForse già presa @Anshuu2004 l’ha presa 1 giorno fa. ApertaBackend first issue bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
TheCodeHeist-Coder/Rexial#192 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Registering without a password returns a 500 instead of telling you what is missingForse già presa @Anshuu2004 l’ha presa 2 giorni fa. ApertaBackend first issue bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TheCodeHeist-Coder/Rexial#191 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CI does not run the frontend testsForse già presa @nayan45633 l’ha presa 1 giorno fa. ApertaBackend first issue good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
TheCodeHeist-Coder/Rexial#188 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TheCodeHeist-Coder/Rexial
Issue simili
-
a10y a10y-audit ai-driven-qa claude
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
linagora/twake-directory-manager#219 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
0️⃣ phase/new
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Pulse v7: buildPreferencesFromTelos() bypasses telosSectionOrFile(), renders empty on unified-TELOS installsForse già presa @zephyr91 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
danielmiessler/LifeOS#2393 ·
I maintainer di solito rispondono entro 4 giorni