Fix Electron dev and packaged renderer startup#3557
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Bug fix for Electron renderer startup with well-tested, limited-scope changes: header stripping for proxied requests, retry logic for transient GET/HEAD failures, and dev-mode CORS configuration. All changes include corresponding tests. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: Julius Marminge <julius@mac.lan>
<!--⚠️ READ BEFORE OPENING⚠️ We are not actively accepting contributions right now. You can still open a PR, but please do so knowing there is a high chance we may close it without merging it, or never review it. - Small, focused PRs are strongly preferred. Bug fixes are most likely to be merged. - New features will most likely just annoy us. - 1,000+ line PRs with a bunch of new features will probably get you banned from the repo. --> ## What Changed <!-- Describe the change clearly and keep scope tight. --> ## Why <!-- Explain the problem being solved and why this approach is the right one. --> ## UI Changes <!-- If this PR changes UI, include clear before/after screenshots. If the change involves motion or interaction, include a short video. Delete this section if not applicable. --> ## Checklist - [ ] This PR is small and focused - [ ] I explained what changed and why - [ ] I included before/after screenshots for any UI changes - [ ] I included a video for animation/interaction changes
Co-authored-by: Julius Marminge <julius@mac.lan>
Co-authored-by: Julius Marminge <julius@mac.lan>
Summary
Verification
Note
Medium Risk
Touches auth-adjacent CORS and the Electron protocol proxy path used for all renderer traffic; changes are scoped to dev origins and idempotent GET/HEAD retries with tests.
Overview
Improves Electron desktop dev and packaged startup by fixing how the custom protocol proxies traffic and how the local API accepts browser calls from the renderer.
ElectronProtocolstrips hop-by-hop and browser-only headers (origin,referer,sec-fetch-*, etc.) before forwarding to Vite/the app server, and retries GET/HEAD fetches up to three times (0/50/150ms) on transient connection failures likeECONNREFUSED.In development, the server CORS layer now allows credentialed preflights from
t3code://appandt3code-dev://appalongside the Vite dev origin. Vite HMR sets an explicitclientPortso the HMR WebSocket connects reliably inside Electron.Marketing bumps Astro from 6 to 7.0.3. Tests cover header sanitization, retry behavior, and desktop-origin CORS preflights.
Reviewed by Cursor Bugbot for commit 41d30ee. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix Electron renderer startup by retrying transient fetch failures and correcting CORS and HMR config
fetchWithTransientRetryinElectronProtocol.tsto retry GET/HEAD requests up to 3 times with short delays (0, 50, 150 ms) on transient failures likeECONNREFUSEDduring renderer startup.origin,referer,sec-fetch-*, etc.) before forwarding proxied requests to the target.t3code://appandt3code-dev://appto allowed CORS origins inapps/server/src/http.tsso credentialed requests from the packaged and dev Electron renderer work correctly.clientPortexplicitly in the Vite HMR config so WebSocket connections work inside the ElectronBrowserWindow.origin,referer, orsec-fetch-*headers to the target.Macroscope summarized 41d30ee.
Toolchain follow-up