Skip to content

fix(public-shares): retry a public read when the shared file is saved mid-read - #10278

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/public-share-read-race
Nov 21, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/public-share-read-race

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A public share read takes a snapshot of the file row, then rechecks the revision (and secret provenance) in a later transaction before delivering bytes. On the streamed path that recheck runs when the stream opens. A collaborative save that commits in between makes the read refuse with 409 Shared file changed during the read.
  • Since Redis became required (chore(redis): require Redis and remove the no-Redis fallbacks #10272), realtime's shared document store persists edits in the markdown-viewer e2e, which now hits this reliably and blocks staging validation. Real viewers and downloaders of a file someone is editing can hit the same 409.
  • Add retryOnSharedFileRevisionChange in the public-shares application layer:
    • It re-runs the whole delivery from a fresh snapshot, up to 3 attempts, only for this race (a dedicated error class; other conflicts still fail at once).
    • Every attempt still refuses mixed revisions and rechecks the grant and provenance, so consistency and secret-safety guarantees are unchanged.
    • Nothing is sent or audited for a refused attempt. Rate limiting is charged once per request.
  • The content (GET/HEAD) and inline routes wrap their read plus response building in it, because the stream's recheck runs on open.

Type of Change

  • Bug fix

Testing

  • New integration check in content-sharing.integration.ts: a real save commits from inside the storage read, for both a streamed Markdown file and a rendered page.
    • A save once: the read is delivered from the fresh snapshot.
    • A save on every attempt: still conflict after exactly 3 writes, proving the retry is bounded.
    • It fails on the pre-fix code with the exact staging error. 14/14 pass with the fix.
  • type-check; check:test-patterns, check:comment-hygiene, check:boundaries, check:source-conventions, check:explicit-any.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 21, 2026 5:14am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Public file reads now retry up to three times when a save changes the file before delivery.

  • Public share reads retry when a file changes mid-read.

No actionable issues found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Apply rate limit and authorize] --> B[Read a fresh file snapshot]
  B --> C[Build response and open stream if needed]
  C --> D{Revision changed?}
  D -->|No| E[Return response]
  D -->|Yes, attempts remain| B
  D -->|Yes, third attempt| F[Return conflict]
  C -->|Other error| G[Return error without retry]
Loading

Reviews (1) · Last reviewed commit: "fix(public-shares): retry a public read ..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 68f8aba into staging Nov 21, 2026
82 of 84 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 42b668d3 Deployed Nov 21, 2026 by vercel[bot]
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