[PR #1601] [MERGED] fix(staffml): use summary fallback when Worker fetch fails in gauntlet #9213

Closed
opened 2026-05-03 01:28:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1601
Author: @Shashank-Tripathi-07
Created: 4/29/2026
Status: Merged
Merged: 4/30/2026
Merged by: @profvjreddi

Base: devHead: fix/gauntlet-partial-hydration


📝 Commits (1)

  • a5cfdbd fix(staffml): use summary fallback when Worker fetch fails in gauntlet

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 interviews/staffml/src/app/gauntlet/page.tsx (+4 -2)

📄 Description

Summary

  • startGauntlet fires Promise.all to pre-hydrate every question's scenario/details from the Cloudflare Worker before the gauntlet starts.
  • The previous guard was if (hydrated.length === selected.length) setQuestions(hydrated) -- meaning if even one Worker response came back undefined, the entire hydrated batch was silently dropped and setQuestions was never called.
  • Users then played the whole gauntlet with empty scenario and details fields on every question, regardless of which questions actually succeeded.

Fix: Map results back to the original selected array per-index, falling back to the summary for any question the Worker couldn't hydrate. Partial Worker failures now degrade gracefully instead of wiping all hydrated data.

// Before
const hydrated = results.filter((q): q is Question => q !== undefined);
if (hydrated.length === selected.length) setQuestions(hydrated);

// After
const merged = selected.map((s, i) => results[i] ?? s);
setQuestions(merged);

Test plan

  • Start a gauntlet normally -- verify questions show scenario/details as before
  • Simulate a Worker outage (DevTools: block staffml-vault.* requests) -- verify gauntlet still starts and shows summary text per question rather than blank scenario
  • Verify gauntlet timer, scoring, and results phases work correctly after the change

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1601 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/30/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/gauntlet-partial-hydration` --- ### 📝 Commits (1) - [`a5cfdbd`](https://github.com/harvard-edge/cs249r_book/commit/a5cfdbd1499794b001779055e47129cec112dba8) fix(staffml): use summary fallback when Worker fetch fails in gauntlet ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `interviews/staffml/src/app/gauntlet/page.tsx` (+4 -2) </details> ### 📄 Description ## Summary - `startGauntlet` fires `Promise.all` to pre-hydrate every question's scenario/details from the Cloudflare Worker before the gauntlet starts. - The previous guard was `if (hydrated.length === selected.length) setQuestions(hydrated)` -- meaning if **even one** Worker response came back `undefined`, the entire hydrated batch was silently dropped and `setQuestions` was never called. - Users then played the whole gauntlet with empty `scenario` and `details` fields on every question, regardless of which questions actually succeeded. **Fix:** Map results back to the original `selected` array per-index, falling back to the summary for any question the Worker couldn't hydrate. Partial Worker failures now degrade gracefully instead of wiping all hydrated data. ```ts // Before const hydrated = results.filter((q): q is Question => q !== undefined); if (hydrated.length === selected.length) setQuestions(hydrated); // After const merged = selected.map((s, i) => results[i] ?? s); setQuestions(merged); ``` ## Test plan - [ ] Start a gauntlet normally -- verify questions show scenario/details as before - [ ] Simulate a Worker outage (DevTools: block `staffml-vault.*` requests) -- verify gauntlet still starts and shows summary text per question rather than blank scenario - [ ] Verify gauntlet timer, scoring, and results phases work correctly after the change --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-03 01:28:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#9213