Skip to content

fix(desktop): never fail the Windows build on NSIS stage cleanup - #438

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/desktop-nsis-stage-cleanup
Nov 29, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/desktop-nsis-stage-cleanup

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

Problem

The v0.0.25 Desktop Release (run 46222864673) failed in Package Windows ARM64 on both attempts with the same error:

Error: EPERM, Permission denied: 'C:\a\mlx-node\mlx-node\packages\desktop\out\.nsis-uninst\.nsis-uninst-stage'
    at rmSync (node:fs:1593:18)
    at buildWindowsUninstaller (packages/desktop/scripts/windows-nsis.ts:763:5)

The two-pass NSIS signing code from #432 never ran in a desktop release before v0.0.25. The finally block removes the stage dir about 1 s after uninst-gen.exe exits, and Windows still holds a handle on that freshly written and executed exe.

npm 0.0.25 is published; only the desktop installers are blocked.

Fix

pre-clean (before each build)   rmSync + retries        → still throws (needs a clean stage)
finally   (after each build)    rmSync + retries        → on failure: warn, continue
  • rmSync gets maxRetries: 10, retryDelay: 250 (about 14 s with linear back-off). Node retries EPERM/EBUSY only with maxRetries.
  • In the two finally blocks, a handle that outlives the retries only warns. The stage dir is outside appPath, and later steps use only the exact Uninstall.exe path (package-windows.ts:303-325, desktop-release.yml:360-367), so a leftover dir is never packaged or signed.

Verification

  • windows-nsis.test.ts: 11 passed. Typecheck and format are clean.
  • The Windows job uses the desktop-release environment (only main and v*), so a branch dry run cannot run it. After merge, I will dispatch a desktop dry run from main (dry_run=true, sign_windows=false) to prove the Windows packaging, then cut 0.0.26.

🤖 Generated with Claude Code

Brooooooklyn and others added 2 commits November 29, 2026 13:38
Windows can still hold a handle on the uninstaller generator exe right after
it runs (AV scan, process teardown), so the stage-dir rmSync in
buildWindowsUninstaller failed with EPERM on the v0.0.25 release run. Node's
rmSync only retries EPERM/EBUSY/ENOTEMPTY when maxRetries is set, so every
NSIS stage-dir removal now passes maxRetries: 10, retryDelay: 250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The v0.0.25 release failed twice, deterministically, with EPERM when the
finally block removed out/.nsis-uninst/.nsis-uninst-stage right after
uninst-gen.exe exited. The stage dir is outside appPath and nothing
reads it later (package-windows.ts and the workflow use only the exact
Uninstall.exe path), so after the retries a remaining handle only warns.
The pre-clean before each build stays strict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9623f61b-051c-4130-b985-d3a3c5d93303

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T05:40:18.431275Z 846c9ad PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Brooooooklyn
Brooooooklyn merged commit b31d423 into main Nov 29, 2026
21 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/desktop-nsis-stage-cleanup branch November 29, 2026 06:20
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