fix(desktop): force rebuild when packaged app is missing node-pty native binary (closes #62462) - #62564
Closed
Snowdchike wants to merge 1 commit into
Closed
fix(desktop): force rebuild when packaged app is missing node-pty native binary (closes #62462)#62564Snowdchike wants to merge 1 commit into
Snowdchike wants to merge 1 commit into
Conversation
Fixes #62462 — `hermes desktop` would silently launch a packaged Electron app whose `pty.node` was missing on Linux, then crash in the main process with "Cannot find module pty.node". The content-hash stamp only proved the source tree was unchanged; it did NOT verify the packaged artifact actually carried a usable native binary, so a previously-built (but broken) artifact could satisfy the stamp forever. Two layers of defense, mirroring the issue's "likely cause" list: 1. `stage-native-deps.mjs` now throws (instead of warn) when no native binary is staged for the target. Empty build/Release/ AND empty prebuilds/<platform>-<arch>/ is the broken state we want to catch. 2. `_desktop_build_needed()` adds a native-deps gate alongside the content stamp. Looks at the same paths the renderer-side node-pty loader checks (build/Release/, prebuilds/<platform>-<arch>/) plus lib/index.js so a future layout change can't silently regress. Tests: 65/65 pass (61 existing + 4 new covering missing-deps detection, prebuild-only layout, lib/index.js regression, arch-suffix mapping).
Contributor
Related to #61798 (competing/complementary fix for the same missing- |
This was referenced Jul 28, 2026
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hermes desktopon Linux could silently launch a packaged Electron app whosepty.nodewas missing, then crash in the main process withCannot find module pty.node. The content-hash stamp only proved the source tree was unchanged — it did NOT verify the packaged artifact actually carried a usable native binary, so a previously-built (but broken) artifact could satisfy the stamp forever.This adds two layers of defense at build-time so the failure surfaces as a loud rebuild, not a runtime crash.
Root cause
The user's reported behavior matches exactly what happens when both:
prebuilds/linux-x64/is empty (no matching prebuild for Electron's Node ABI), ANDbuild/Release/is empty (@electron/rebuildwas never run)…because both paths fall through,
node-ptyships into the package with its JS surface intact but no.nodebinary, and Electron dies loadingunixTerminal.jsat startup.The existing stamp check in
_desktop_build_needed()would happily mark the broken package "up to date (content stamp matches)" because the source tree hadn't changed since the broken build was produced.Changes
apps/desktop/scripts/stage-native-deps.mjs— fail loud, not silentbuild/Release/andprebuilds/<platform>-<arch>/lack a*.nodebinary orspawn-helper.npx @electron/rebuild -w node-pty --platform <p> --arch <a>.hermes_cli/main.py— native-deps gate alongside content stamp_desktop_native_deps_present()checks the same paths node-pty's loader checks (build/Release/, prebuilds/-/) pluslib/index.jsfor defensive coverage._native_arch_suffix()returns the canonical<platform>-<arch>dir name (linux-x64, linux-arm64, darwin-arm64, win32-x64, …) without duplicating the lookup logic in 5 places._desktop_unpacked_resources_root()centralizes how we locateapp.asar.unpacked/.../resources/dist/node_modules/node-pty— stays in sync with_desktop_packaged_executable._desktop_build_needed()now returnsTruewhen native deps are missing, forcing a rebuild.tests/hermes_cli/test_gui_command.py— coverage_make_packaged_executablehelper updated to stage realistic node-pty payload (lib/index.js + build/Release/pty.node) by default;with_native_deps=Falseopt-out for the missing-deps test.Verification
End-to-end smoke test of the mjs change confirmed the new validation throws with the expected error message when both build/Release/ and prebuilds/linux-x64/ are empty.
Notes
apps/desktop/release/linux-unpacked/resources/app.asar.unpacked/dist/node_modules/node-pty/build/Release/pty.node) — this only affects installs where the staging step produced an incomplete payload.Closes #62462