Skip to content

fix(relay): a switch-file read cut off mid-body is asked for again - #27049

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-flag-seen-generation
Oct 10, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-flag-seen-generation

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

Each cell reads its switch file from Cloud Storage every 5 s. If one read was cut off halfway, the cell wrongly remembered that version as read and never asked for it again, so that switch change never took effect on that cell. Now it asks again.

What Changed

relay-control-flag-channel.ts set seenGeneration before reading the body. A read that failed mid-body (connection reset, timeout, past the 64 KiB bound) then made every later poll send ifGenerationNotMatch=<that generation>, which Cloud Storage answers with 304, so the write was stranded until the object changed again. The generation is now recorded only after the body has been read and parsed as JSON. A body that parses but is void (a bad known value) is still recorded, so it is not re-read every 5 s (unchanged).

Why

From the second-roll audit. Every step-5 flip and every flip back goes through this channel, so a stranded read would break the ≤ 15 s revert. It must ride the one cell image.

Linked Issue

N/A (internal relay redesign, step 5).

Visual Proof

N/A: server-side, no UI.

Testing

  • New test: a body that errors mid-stream leaves the applied generation at 0, the next poll asks without ifGenerationNotMatch and applies it. The test fails without the fix.
  • Existing tests (void object not re-read, lost contact keeps values, the 64 KiB bound) pass.

The flag channel recorded a generation as seen before reading its body, so a
read that failed mid-body sent ifGenerationNotMatch for it on every later poll
and got 304 forever: that write was stranded until the object changed again.
The generation now counts as seen only once its body has been read and parsed.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8bc3f905-43da-485a-86a2-c05aa3f2a14f

📥 Commits

Reviewing files that changed from the base of the PR and between 3dd332e and 592774b.


📒 Files selected for processing (2)
  • cloud/apps/relay/src/relay-control-flag-channel.test.ts
  • cloud/apps/relay/src/relay-control-flag-channel.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The channel now records a generation only after it completes a bounded response-body read and parses the JSON successfully. A test covers a truncated response, a retry without ifGenerationNotMatch, and applying the complete response.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 59277

Switch-file reads that are cut off mid-body will now be retried on the next poll instead of being stuck on 304 responses. No actionable merge risk remains.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: retrying a switch-file read when the response body is cut off mid-read.
Description check Passed The description covers the user impact, technical change, rationale, linked-issue context, visual-proof exception, and testing. It omits the optional AI Disclosure, Review, Agent skill boundary, Notes…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant