Skip to content

fix(desktop-windows): guard packaged startup before auto-update handoff - #13858

Merged
Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/fix-windows-update-handoff-10849-de0a
Oct 1, 2026
Merged

Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/fix-windows-update-handoff-10849-de0a

Conversation

@apoorvdarshan

@apoorvdarshan apoorvdarshan commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10849

Summary

Reporter feedback on #10849 clarified the failure mode: Settings → About → Restart to update closes Omi and runs the NSIS updater, but the installed build then crashes on launch with Cannot find module 'ms' (same packaging boundary as #10738). That looks like an uninstall-without-reinstall from the user’s perspective.

Root cause on affected releases: electron-builder’s dependency collection shipped Sentry’s debug chain without hoisted ms in the final Windows artifact. main already pins electron-builder ~26.15.x, which includes the transitive dep; this PR adds a final-artifact probe so broken installers cannot reach the auto-update feed again, plus two updater handoff hardening tweaks.

Changes

  1. verify-packaged-main-runtime.mjs — After win-unpacked is built, run the packaged Electron binary with ELECTRON_RUN_AS_NODE and resolve @sentry/electron/main → debug → ms through the same ASAR loader the app uses at startup.
  2. CI / release — build:win and new build:win:unpack run the probe; Windows CI uses build:win:unpack; signed release path runs pnpm verify:packaged-main after electron-builder.
  3. Updater handoff — Defer quitAndInstall with setImmediate so Electron finishes quitting before NSIS update.exe runs (avoids assisted-installer getting stuck after uninstall). Set explicit runAfterFinish: true on the NSIS target.

Product invariants affected

none

Failure class

Failure-Class: FC-runtime-image-boundary

Verification

From desktop/windows:

node node_modules/vitest/vitest.mjs run \
  scripts/verify-packaged-main-runtime.test.mjs \
  scripts/build-scripts-publish.test.mjs \
  src/main/updater.test.ts

20 tests passed.

Full Windows build:win:unpack + live probe requires a Windows runner (Desktop Windows CI).

Review in cubic

September 30 metadata verification

Validated the current PR metadata locally with scripts/pr-preflight --metadata-only; refreshing this description retriggers the previously cancelled metadata preflight. The packaging/runtime checks on the code head were already passing. The Windows scope-hint suggestion is non-blocking and belongs in a separate registry-only lifecycle PR under the failure-class protocol.

apoorvdarshan and others added 2 commits September 8, 2026 22:29
chore: sync fork main from BasedHardware/omi
Fixes BasedHardware#10849.

The in-app "Restart to update" path was installing Windows releases that
crashed on launch (Cannot find module 'ms') when electron-builder omitted
Sentry's debug/ms chain. Add a final-artifact probe on win-unpacked builds,
wire it into CI and release packaging, defer quitAndInstall so NSIS can
complete assisted updates, and set runAfterFinish on the NSIS target.

Failure-Class: FC-runtime-image-boundary

Verified: node node_modules/vitest/vitest.mjs run (from desktop/windows)
  scripts/verify-packaged-main-runtime.test.mjs
  scripts/build-scripts-publish.test.mjs
  src/main/updater.test.ts — 20 passed

Co-authored-by: Apoorv Darshan <[email protected]>
@apoorvdarshan
apoorvdarshan marked this pull request as ready for review September 14, 2026 16:00

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

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

Re-trigger cubic

Resolve ms from debug's module graph instead of Sentry's require root,
and fail when ms/main/Sentry paths fall outside OMI_PACKAGED_APP_ROOT.

Addresses cubic P1 on BasedHardware#13858.

Verification: verify-packaged-main-runtime.test.mjs (9 passed).

Co-authored-by: Apoorv Darshan <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end against the packaged artifact — this is a well-built guard. Per-file notes below.

New guard:

  • desktop/windows/scripts/verify-packaged-main-runtime.mjs — the probe is properly defensive: a strict env allowlist (COMSPEC/PATH/PATHEXT/SYSTEMROOT/TEMP/TMP/WINDIR) so signing secrets can't reach the child, ELECTRON_RUN_AS_NODE with -e, resolving @sentry/electron/main -> debug -> ms without initializing Sentry (no telemetry from release runners), a 30s timeout, fail-closed on missing success marker or malformed details, and assertPathInsidePackagedRoot so a host node_modules resolution can't produce a false positive.
  • desktop/windows/scripts/verify-packaged-main-runtime.test.mjs — the negative cases are the valuable ones: host-escape rejection, non-zero exit surfacing "Cannot find module 'ms'", missing-marker fail-closed, and refusal to run anything but omi-windows.exe. All 9 tests pass in the Typecheck-Lint-Test job.
  • Live check: the Windows build smoke job on this head ran build:win:unpack and its log shows "[verify-packaged-main] PASS - packaged Sentry/debug runtime resolves ms." against the real dist/win-unpacked artifact (run 34871189164).

Wiring:

  • desktop/windows/package.json — build:win and the new build:win:unpack both chain verify:packaged-main after electron-builder; since the unsigned release path runs pnpm build:win, both signed and unsigned installers are gated.
  • .github/workflows/desktop_windows_release.yml — explicit pnpm verify:packaged-main after the signed Azure build; correct placement before artifacts are collected.
  • .github/workflows/desktop-windows-ci.yml — CI now exercises build:win:unpack (real packaging + probe on windows-latest) instead of build:unpack, and now also triggers on release-workflow changes — right call given the two are coupled.
  • desktop/windows/scripts/build-scripts-publish.test.mjs — the ordering assertions (probe after electron-builder in both scripts and the signed workflow step) keep the gate from being silently reordered later.

Updater handoff:

  • desktop/windows/src/main/updater.ts — deferring quitAndInstall via setImmediate so Electron finishes the quit handshake before NSIS update.exe runs is a plausible fix for the stuck-assisted-installer failure mode; updater.test.ts correctly moves to vi.waitFor for the deferred call.
  • desktop/windows/electron-builder.config.mjs — runAfterFinish: true is the NSIS default for assisted (oneClick: false) installs, but stating it explicitly next to that block documents intent well.
  • desktop/windows/changelog/unreleased/2026-09-windows-update-packaging-guard.json — matches the existing unreleased-changelog convention.
  • .github/failure-classes/FC-runtime-image-boundary.json — good addition of the probe to canonical_prevention_artifact. One small polish (also noted by the cubic review): scope_hints still lists only backend/plugins/gcp paths, so failure-class tooling may not associate changes to the new artifact; consider adding desktop/windows/scripts/**.

Two things for a maintainer:

  1. Overlap with test(desktop-windows): verify packaged Sentry dependencies #10823 — that open PR implements the same guard in the same 7 files, including a same-named verify-packaged-main-runtime.mjs, and carries an approval. This PR is a strict superset (host-escape assertions, update-flow framing, updater hardening, changelog entry), but one of the two should be chosen before merge to avoid conflicts — maintainer call.
  2. The updater handoff changes (setImmediate defer, runAfterFinish) can't be exercised by CI against a real update flow. The release-path gating added here is the right compensating control for packaging, but the NSIS handoff behavior itself needs maintainer sign-off.

Leaving for human maintainer review given the duplicate-PR decision and the release-pipeline surface.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior needs-maintainer-review Needs a human maintainer to sign off before merge windows Windows desktop work labels Sep 14, 2026
kodjima33 pushed a commit that referenced this pull request Sep 15, 2026
…mage-boundary (#13869)

Registry-only scope_hints update so failure-class prepare surfaces
FC-runtime-image-boundary for Windows packaging/probe work.

Addresses cubic P3 on #13858.

Co-authored-by: Cursor Agent <[email protected]>

@aryanorastar aryanorastar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on 1ff95cc.

Packaged Windows startup is probed after electron-builder (verify:packaged-main) before the auto-update feed, and runAfterFinish is on for assisted updates. Tests pin the verify step after both build:win scripts and the signed-release workflow.

This touches .github/workflows/** (CODEOWNERS @Git-on-my-level). My approve is not a fake David CODEOWNERS review. I am not merging.

@Git-on-my-level
Git-on-my-level merged commit c0cffbc into BasedHardware:main Oct 1, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution windows Windows desktop work workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Omi Windows desktop "Restart to install latest update" removes the app but does not reinstall it

4 participants