Skip to content

refactor(relay): API-served relay endpoint, and deploy relay2 with production - #6204

Merged
saddlepaddle merged 1 commit into
mainfrom
relay2-deploy-ci
Aug 5, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
relay2-deploy-ci

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Two things relay2 needs that missed the #6165 merge.

1. The API decides which relay you're on

Tonight's rollout attempt exposed that relay config delivery — not the relay — is the fragile part. Three separate failures, all from evaluating the PostHog flag on the client:

  • Spawn race. The desktop resolved the relay URL when spawning host-service, and getRelayUrl() silently returns the default when PostHog hasn't identified the user yet. A cold start usually loses that race, so the host locks onto the old relay and never re-checks — restarting the app just replays it. One machine sat on the wrong relay through three restarts with no error anywhere.
  • Split-brain. Clients read the flag live; hosts read it at spawn. Flipping the flag pointed every client at the new relay while every host was still on the old one, which surfaced as a wall of 503s and Host is not online.
  • No observability. Nothing records which relay a host actually chose, so the only way to tell was reading relay-side logs and inferring.

host.relayEndpoint (jwtProcedure) resolves the flag server-side, once, and the host-service, renderer, and CLI all read that same answer. The host-service asks for itself after authenticating instead of trusting what spawned it, so there's no identification to race. env.RELAY_URL remains the fallback for an unreachable API.

2. relay2 deploys with production

A deploy-relay2 job in deploy-production.yml, a copy of deploy-electric-proxy using the same runner, cache, and Cloudflare secrets. Until this lands, relay2 deploys are manual wrangler deploy.

https://claude.ai/code/session_01A2JifsfA63nWthegPwNt8G

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The production workflow adds a deploy-relay2 job. The job sets up Bun, restores and installs dependencies, configures Cloudflare credentials, and deploys apps/relay2 with Wrangler.

Changes

Relay2 production deployment

Layer / File(s) Summary
Deploy Relay2 Worker
.github/workflows/deploy-production.yml
Adds the deploy-relay2 job with Bun setup, dependency caching and installation, Cloudflare credential configuration, and Wrangler deployment from apps/relay2.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly describes the addition of automated relay2 deployment and follows conventional commit format.
Description check ✅ Passed The description explains the change, rationale, deployment configuration, and current manual process, but omits the template headings, test results, and checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch relay2-deploy-ci

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.

@saddlepaddle saddlepaddle changed the title ci(relay): deploy relay2 with production and fail if it doesn't serve ci(relay): deploy relay2 alongside electric-proxy Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Relay2 to the production deployment workflow and verifies after deployment that its public health endpoint serves protocol version 2.

  • Installs the monorepo dependencies and deploys apps/relay2 through Wrangler using the existing Cloudflare credentials.
  • Polls the Relay2 health endpoint for up to two minutes and fails the job unless the expected protocol marker appears.

Confidence Score: 5/5

The PR appears safe to merge, with the deployment target and expected health response consistent with Relay2’s current configuration and endpoint contract.

The new job follows the existing Cloudflare deployment pattern, deploys the pinned Relay2 workspace tooling, and validates the documented Worker URL and protocol response with bounded retries.

Important Files Changed

Filename Overview
.github/workflows/deploy-production.yml Adds a production Relay2 deployment job with pinned actions, frozen dependency installation, Wrangler deployment, and bounded post-deployment health verification.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Production workflow starts] --> B[Checkout repository]
  B --> C[Set up Bun and restore cache]
  C --> D[Install frozen dependencies]
  D --> E[Deploy Relay2 with Wrangler]
  E --> F{Health response contains proto: 2?}
  F -->|Yes| G[Deployment job succeeds]
  F -->|No, attempts remain| H[Wait 10 seconds]
  H --> F
  F -->|No, after 12 attempts| I[Deployment job fails]
Loading

Reviews (1): Last reviewed commit: 57d2169 | Re-trigger Greptile

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy-production.yml:
- Around line 503-508: Add a post-deployment health-check step after the “Deploy
Worker” step, reusing the bounded polling logic from deploy-electric-proxy to
query production’s /health endpoint for up to two minutes. Parse the response
and fail the workflow unless Relay2 reports proto: 2.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b6cb620-ee0e-49a1-9aa6-7b92c63919c4

📥 Commits

Reviewing files that changed from the base of the PR and between b2552e3 and b832d52.

📒 Files selected for processing (1)
  • .github/workflows/deploy-production.yml

Comment on lines +503 to +508
- name: Deploy Worker
working-directory: apps/relay2
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: bunx wrangler deploy

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add the required post-deployment health check.

Line 508 is the final step. It only confirms that Wrangler accepted the upload. It does not poll the production /health endpoint for up to two minutes or verify proto: 2. Add the same bounded health check used by deploy-electric-proxy, and fail the job unless Relay2 reports proto: 2.

🧰 Tools
🪛 zizmor (1.29.0)

[warning] 479-508: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-production.yml around lines 503 - 508, Add a
post-deployment health-check step after the “Deploy Worker” step, reusing the
bounded polling logic from deploy-electric-proxy to query production’s /health
endpoint for up to two minutes. Parse the response and fail the workflow unless
Relay2 reports proto: 2.

@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.

1 issue found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/deploy-production.yml">

<violation number="1" location=".github/workflows/deploy-production.yml:482">
P2: Concurrent pushes can leave relay2 serving an older commit than the latest production run because this job has no deployment serialization. Add a job-level concurrency group with `cancel-in-progress: false` so relay2 deployments complete in commit order.</violation>
</file>

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

Re-trigger cubic

deploy-relay2:
name: Deploy Relay2 to Cloudflare
runs-on: ubuntu-latest
environment: production

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.

P2: Concurrent pushes can leave relay2 serving an older commit than the latest production run because this job has no deployment serialization. Add a job-level concurrency group with cancel-in-progress: false so relay2 deployments complete in commit order.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/deploy-production.yml, line 482:

<comment>Concurrent pushes can leave relay2 serving an older commit than the latest production run because this job has no deployment serialization. Add a job-level concurrency group with `cancel-in-progress: false` so relay2 deployments complete in commit order.</comment>

<file context>
@@ -476,6 +476,53 @@ jobs:
+  deploy-relay2:
+    name: Deploy Relay2 to Cloudflare
+    runs-on: ubuntu-latest
+    environment: production
+
+    steps:
</file context>
Suggested change
environment: production
environment: production
concurrency:
group: deploy-relay2
cancel-in-progress: false

@saddlepaddle
saddlepaddle merged commit 4b05614 into main Aug 5, 2026
19 checks passed
@saddlepaddle saddlepaddle changed the title ci(relay): deploy relay2 alongside electric-proxy refactor(relay): API-served relay endpoint, and deploy relay2 with production Aug 5, 2026

This branch was previously deployed

1 inactive deployment
preview — b832d524 Deployed Aug 5, 2026 by saddlepaddle via Deploy Docs #7165
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