Skip to content

fix(server): invalidate CloudFront for build routes on new build - #381

Open
yuvrajjsingh0 wants to merge 1 commit into
mainfrom
feat/invalidate-cf-on-build
Open

yuvrajjsingh0 wants to merge 1 commit into
mainfrom
feat/invalidate-cf-on-build

Conversation

@yuvrajjsingh0

Copy link
Copy Markdown
Contributor

Problem

When a build produces a new zip/aar and writes a new version row, nothing purges the CloudFront cache for the /build routes.

The only invalidate_cf call sites are in release.rs (create / ramp / conclude), and they all invalidate /release/{org}/{app}*. That glob never matches /build/{org}/{app} — the build routes are a separate scope (main.rs).

Meanwhile serve_version explicitly sets a day-long edge TTL:

HeaderValue::from_static("public, s-maxage=86400, max-age=0")

and the zip / aar bodies change with every version. So clients keep getting the previous version for up to 24h after a new one is ready.

Worst case is the background build path (x-force: false): the request returns the old version immediately and builds the new one in a tokio::spawn. That stale response is what gets cached at the edge, and the build that follows has no way to clear it.

Fix

Add an invalidate_build_cf(state, org, app) helper in build.rs that purges /build/{org}/{app}*, and call it at the end of build().

It runs after the artifacts are uploaded (Step 2), the row is marked READY (Step 3), and build.last_created_build_rid is updated (Step 5) — invalidating any earlier would let a request racing in behind the purge resolve the old release id and re-cache the stale version.

Failures are logged rather than propagated, matching the existing release-side call sites: the build itself has already succeeded by that point.

Notes

  • No new env vars or routes — reuses CLOUDFRONT_DISTRIBUTION_ID and release::utils::invalidate_cf, so no docs change is needed.
  • Unrelated but worth checking on the infra side: whether the cache policy for /build/* includes the x-dimension header in the cache key. The response varies by dimension, so if it isn't keyed on that, different cohorts share one cached entry — a separate issue this PR doesn't address.

Testing

cargo check and cargo clippy pass clean on airborne_server.

@semanticdiff-com

semanticdiff-com Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  airborne_server/src/build.rs  0% smaller

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@yuvrajjsingh0, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77a09bd0-176a-4909-af4e-4f0d583a2570

📥 Commits

Reviewing files that changed from the base of the PR and between 8862e15 and d78346d.

📒 Files selected for processing (1)
  • airborne_server/src/build.rs

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.

@yuvrajjsingh0
yuvrajjsingh0 force-pushed the feat/invalidate-cf-on-build branch from 8f58764 to 813648c Compare August 4, 2026 13:47
@yuvrajjsingh0
yuvrajjsingh0 force-pushed the feat/invalidate-cf-on-build branch from 813648c to d78346d Compare August 17, 2026 07:49
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