Repository navigation
fix(desktop): hard-fail builds that externalize @grida/* workspace packages - #776
Conversation
…ckages
Desktop 0.0.3 shipped a main.js containing a bare
`require("@grida/desktop-bridge")` that resolved to nothing at runtime,
crashing the app on launch with "Cannot find module" — while every CI
check was green.
Root cause: the desktop `link:`s several @grida/* workspace packages
whose dist/ is gitignored. The isolated ./desktop release CI runs
`pnpm install` (which only symlinks link deps) and never builds them, so
Rollup couldn't resolve the import and silently downgraded it to an
external `require`. The symlink resolves, types exist, and local dev has
dist/ built — so nothing catches it until a clean packaging run.
Two-part fix:
1. CI builds the desktop's @grida/* link-dep closure before packaging, so
the green path actually produces a working binary.
2. A Vite plugin guard (wired into all three entries: main, preload,
agent-sidecar) inspects the EMITTED bundle and, if any @grida/* import
was left external, prints to stderr and process.exit(1). This is a
plugin-that-exits rather than an onwarn handler because forge runs the
Vite build with logLevel:"silent", which swallows Rollup's
UNRESOLVED_IMPORT warning AND a throw inside onwarn (verified — that
approach builds green and ships the broken bundle). Scoped
apply:"build" so dev (`electron-forge start`) is unaffected.
Verified against the real `pnpm package`: with dist/ hidden the build now
hard-fails with a clear, actionable message; with dist/ present it
packages cleanly with the bridge inlined. The original runtime crash was
reproduced locally on the pre-fix tree.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 7 Skipped Deployments
|
WalkthroughThis PR adds a Vite bundle guard plugin to detect when workspace-scoped packages remain external instead of bundled, applies the plugin to three desktop Vite configurations, and updates the CI workflow to pre-build workspace packages before desktop publishing, preventing runtime "Cannot find module" errors. ChangesDesktop bundle guard and workspace package preparation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/realease-desktop-app.yml (1)
99-121: Add a lightweight packaged-app boot smoke test after publish steps.This workflow now prevents unresolved
@grida/*externals at build-time; adding one post-package launch check would catch any remaining runtime startup regressions before release consumers do.🤖 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/realease-desktop-app.yml around lines 99 - 121, Add a lightweight packaged-app boot smoke test step that runs immediately after each "Publish App (Windows)", "Publish App (Linux)", and "Publish App (MacOS)" publish step: for each OS matrix variant add a new step named e.g. "Smoke Test Packaged App" which locates the produced package/installer from the workspace or artifacts and performs a non-interactive startup check (invoke the packaged binary or executable with a stable flag such as --version or --help, or run the AppImage/.exe/.app binary briefly) and fails the job on non-zero exit; ensure the step is conditional on the same if-expressions used for the publish steps and reuses the same env vars (GITHUB_TOKEN, PRERELEASE, signing envs) so it runs in CI after publishing to catch runtime startup regressions.
🤖 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.
Nitpick comments:
In @.github/workflows/realease-desktop-app.yml:
- Around line 99-121: Add a lightweight packaged-app boot smoke test step that
runs immediately after each "Publish App (Windows)", "Publish App (Linux)", and
"Publish App (MacOS)" publish step: for each OS matrix variant add a new step
named e.g. "Smoke Test Packaged App" which locates the produced
package/installer from the workspace or artifacts and performs a non-interactive
startup check (invoke the packaged binary or executable with a stable flag such
as --version or --help, or run the AppImage/.exe/.app binary briefly) and fails
the job on non-zero exit; ensure the step is conditional on the same
if-expressions used for the publish steps and reuses the same env vars
(GITHUB_TOKEN, PRERELEASE, signing envs) so it runs in CI after publishing to
catch runtime startup regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: db807154-2564-46d6-9ae0-cfa5f5a310c5
📒 Files selected for processing (6)
.github/workflows/realease-desktop-app.ymldesktop/vite.agent-sidecar.config.tsdesktop/vite.guards.test.tsdesktop/vite.guards.tsdesktop/vite.main.config.tsdesktop/vite.preload.config.ts
What
Desktop 0.0.3 shipped a
main.jscontaining a barerequire("@grida/desktop-bridge")that resolved to nothing at runtime — the app crashed on launch withCannot find module '@grida/desktop-bridge', while every CI check was green.This adds a build-time guard that makes that class of failure a hard, visible error, plus the CI step that fixes the happy path.
Why it happened (etiology)
The desktop
link:s several@grida/*workspace packages whosedist/is gitignored. The isolated./desktoprelease CI runspnpm install(which only symlinks link deps) and never builds them. So at package time Rollup couldn't resolve the import and silently downgraded it to an externalrequire, and electron-forge runs the Vite build withlogLevel:"silent"so even theUNRESOLVED_IMPORTwarning vanished.It's uniquely dangerous because every gate stays green: the symlink resolves, types exist, and local dev has
dist/built — so it only breaks in a clean packaging run.The fix (two parts)
realease-desktop-app.yml) —@grida/desktop-bridge,@grida/agent,@grida/ai-models,@grida/home— so the green path actually produces a working binary.desktop/vite.guards.ts), wired into all three entries (main, preload, agent-sidecar). It inspects the emitted bundle and, if any@grida/*import was left external, prints to stderr andprocess.exit(1).Why a plugin-that-exits, not
onwarnonwarnwas the obvious first attempt — and it's a trap. Verified against the real packager: Rollup does emitUNRESOLVED_IMPORTand forge does forward it to a useronwarn, but a throw insideonwarnis swallowed and the build still succeeds. Eventhis.error()only surfaces as a cryptic downstream "main entry point not found" because forge's logger is silent. Inspecting the emitted bundle +process.exit(1)is the only reliable, visible hard-fail. Scopedapply:"build"so dev (electron-forge start) is unaffected.Verification
dist/, build, loadmain.jsvia electron-as-node →MODULE_NOT_FOUNDthrough the sameelectron node_init → _load → _resolveFilenamepath as the report).pnpm packagewithdist/missing — exit 1, clear message, offender named, actionablepnpm build:packagesfix.dist/present — packages cleanly, bridge inlined; intentional externals (sandbox-runtime,hono,undici) untouched.tsc, oxlint all green.Reviewer notes
Summary by CodeRabbit
Release Notes
Chores
Tests