fix(electron): restore packaged desktop app loading#1095
Conversation
Rebuild and verify Electron native modules before packaging and use the Vite base URL for packaged asset preloads.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a pre-package native module rebuild-and-verify step to CI and build scripts, introduces a verification script for Electron native modules, documents a better-sqlite3 ABI packaging issue, and updates asset URL resolution for preload logic and its tests. Changes
Sequence Diagram(s)sequenceDiagram
participant CI as CI Job / Developer
participant Scripts as npm/yarn scripts
participant Electron as Electron (ELECTRON_RUN_AS_NODE)
participant Native as Native Modules (e.g., better-sqlite3)
participant Packager as electron-forge
CI->>Scripts: yarn build && yarn build:preload
Scripts->>Scripts: yarn electron:prepare-package
Scripts->>Electron: spawn Electron + inline verifier (ELECTRON_RUN_AS_NODE=1)
Electron->>Native: require('better-sqlite3') (and others)
alt require succeeds
Electron-->>Scripts: prints "native-ok"
Scripts->>Packager: electron-forge package / make
else require fails
Electron-->>Scripts: prints "native-fail" + stack
Scripts-->>CI: exit non-zero (fail CI / halt packaging)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
215-216: Consider a packaged-artifact smoke test here.This step verifies the host
node_modulesbefore packaging, but issue#1094only showed up after packaging. Launching one packaged desktop artifact and waiting for the local RPC port would catch ASAR/unpack andfile://regressions that this pre-package check can't see.Also applies to: 280-281, 345-346, 411-413
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 215 - 216, Add a packaged-artifact smoke test after the packaging step instead of only pre-package checks: after the existing "Rebuild and verify Electron native modules" step that runs `yarn electron:prepare-package`, add steps to produce a packaged desktop artifact, launch that packaged binary, and wait/poll the local RPC port to confirm the app starts correctly (catching ASAR/unpack and file:// regressions). Ensure the step gracefully kills the process after verifying the RPC port and fails the job on timeout; apply the same packaged-app smoke-test pattern to the other similar CI spots that run `yarn electron:prepare-package` (the duplicate steps holding the same name/command).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/utils/__tests__/misc-utils.test.ts`:
- Around line 119-123: Update the test to simulate a non-root BASE_URL (e.g.,
set import.meta.env.BASE_URL = 'file:///app/') so the test exercises the
packaged-electron path; then adjust the expected array to the concrete
file:///app/... URLs (the expectation comparing loadedSources) to verify the
code uses `${import.meta.env.BASE_URL}${path}` rather than `/${path}`; locate
the assertion on loadedSources in misc-utils.test.ts and change the test setup
and expected values accordingly.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 215-216: Add a packaged-artifact smoke test after the packaging
step instead of only pre-package checks: after the existing "Rebuild and verify
Electron native modules" step that runs `yarn electron:prepare-package`, add
steps to produce a packaged desktop artifact, launch that packaged binary, and
wait/poll the local RPC port to confirm the app starts correctly (catching
ASAR/unpack and file:// regressions). Ensure the step gracefully kills the
process after verifying the RPC port and fails the job on timeout; apply the
same packaged-app smoke-test pattern to the other similar CI spots that run
`yarn electron:prepare-package` (the duplicate steps holding the same
name/command).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 46c46784-c847-4c99-857b-143aa644438a
📒 Files selected for processing (6)
.github/workflows/ci.ymldocs/agent-playbooks/known-surprises.mdpackage.jsonscripts/verify-electron-native-modules.jssrc/lib/utils/__tests__/misc-utils.test.tssrc/lib/utils/preload-utils.ts
|
Addressed the valid review finding in I am deferring the broader packaged-artifact CI smoke test suggestion for a follow-up because it expands the PR scope and would materially lengthen the packaging matrix further; the current PR remains focused on restoring packaged app loading and verifying the Electron-native module ABI. |
Restore packaged desktop loading by rebuilding Electron-native modules before every package/make flow and by using the Vite base URL for preloaded theme assets in
file://builds.Closes #1094
Note
Medium Risk
Touches Electron packaging/CI and adds a new native-module verification step that runs Electron during builds; failures could block releases but scope is limited to build/runtime asset paths.
Overview
Fixes packaged Electron builds that could ship with an incompatible
better-sqlite3binary by addingelectron:prepare-package(rebuild viaelectron-rebuild+ verification) and running it in CI packaging jobs and allelectron:package/electron:build*scripts.Updates theme asset preloading to resolve URLs via
import.meta.env.BASE_URL(newresolveAssetUrl) instead of hardcoded root paths, and extends tests accordingly. Adds a playbook note documenting thebetter-sqlite3packaging failure mode and mitigation.Written by Cursor Bugbot for commit cf326a2. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
Bug Fixes
Documentation
Chores