Electron sample e2e fails: Electron 42 removed postinstall binary download
bug
## Summary
The lectron sample test ( .github/workflows/test-samples.yml → `electron` job) started failing on **all PR runs** beginning **2026-05-06 PM PT**. Root cause is external: Electron **v42.0.0** was published as the `latest` dist-tag on 2026-05-06 01:28 UTC and removed the postinstall step that previously placed the binary at `node_modules/electron/dist/electron.exe` (security hardening against npm supply-chain attacks). The binary is now downloaded lazily on first launch, or on demand via the new `install-electron` script.
## Impact
- `samples/electron/test.Tests.ps1` Phase 1 (from-scratch guide) installs `create-electron-app@latest` → `electron@42.0.0` → no binary present → `winapp node add-electron-debug-identity` throws `Electron executable not found at: ...\node_modules\electron\dist\electron.exe`.
- Real users following `docs/guides/electron/setup.md` will hit the same error when their `postinstall` script runs `winapp node add-electron-debug-identity` on Electron 42+.
## Failing log excerpt
`
Failed to add Electron debug identity: Electron executable not found at:
...\electron-app\node_modules\electron\dist\electron.exe
[-] Should add Electron debug identity 769ms
`
Source: `src/winapp-npm/src/msix-utils.ts:92-94`.
## Decision
Do **not** auto-download Electron from our SDK (keeps us out of Electron's install business and avoids surprising network calls). Instead, surface a clear, actionable error message and document the new step.
## Proposed fix
1. **`src/winapp-npm/src/msix-utils.ts`** — replace the terse `Electron executable not found` error with messages that distinguish:
- `node_modules/electron` missing → `Electron is not installed. Run
pm install first.`
- `node_modules/electron` present, version ≥ 42, exe missing → `Electron 42+ no longer downloads its binary during
pm install. Run
px install-electron to download it, then re-run this command.`
- Other case → existing path with a reinstall hint.
2. **`samples/electron/test.Tests.ps1`** — add an `npx install-electron` step before the `Should add Electron debug identity` step so Phase 1 (which uses `create-electron-app@latest`) passes again.
3. **`docs/guides/electron/setup.md`** — update the recommended `postinstall` snippets (and the cross-platform `scripts/postinstall.js` variant) to include `npx install-electron` for Electron 42+.
`samples/electron/package.json` is pinned to `electron@39.8.5` and the old auto-download flow still works there, so no change needed for Phase 2.
## References
- Electron 42 release notes: https://github.com/electron/electron/releases/tag/v42.0.0
- Electron PR adding `install-electron`: electron/electron#49328
0 条评论