Skip to content

fix: guard resetSignTool against undefined backup path - #601

Merged
VerteDinde merged 1 commit into
mainfrom
fix/reset-signtool-undefined-path
Jun 28, 2026
Merged

fix: guard resetSignTool against undefined backup path#601
VerteDinde merged 1 commit into
mainfrom
fix/reset-signtool-undefined-path

Conversation

@claude

@claude claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Requested by Samuel Attard · Slack thread

Fixes #576

Before

resetSignTool() calls fs.existsSync(BACKUP_SIGN_TOOL_PATH), but BACKUP_SIGN_TOOL_PATH is a module-level variable that is only assigned inside createSignTool. Since resetSignTool() is called unconditionally from index.ts (including on the no-sign path, before any signing branch), on its first call the path is undefined. fs.existsSync(undefined) emits Node's DEP0187 deprecation warning, and the restore silently becomes a no-op (correctly, but only by accident).

After

resetSignTool() guards the existsSync + restore so it is skipped while BACKUP_SIGN_TOOL_PATH / ORIGINAL_SIGN_TOOL_PATH are still undefined. No more DEP0187 warning, and the restore only runs once the paths have actually been initialized by createSignTool.

How

The signtool paths are module-level let bindings assigned only in createSignTool. resetSignTool is invoked unconditionally regardless of whether signing options were provided, so it can run before those bindings are set. The fix adds a truthiness check on the paths before touching the filesystem.

-  if (fs.existsSync(BACKUP_SIGN_TOOL_PATH)) {
+  if (BACKUP_SIGN_TOOL_PATH && ORIGINAL_SIGN_TOOL_PATH && fs.existsSync(BACKUP_SIGN_TOOL_PATH)) {

Generated by Claude Code

BACKUP_SIGN_TOOL_PATH and ORIGINAL_SIGN_TOOL_PATH are module-level
variables only assigned inside createSignTool. resetSignTool is called
unconditionally (including on the no-sign path), so on its first call
the paths are undefined and fs.existsSync(undefined) triggers Node's
DEP0187 deprecation warning. Guard the existsSync/restore so it is
skipped until the paths have been initialized.

Fixes #576
@MarshallOfSound
MarshallOfSound marked this pull request as ready for review June 27, 2026 21:41
@MarshallOfSound
MarshallOfSound requested a review from a team as a code owner June 27, 2026 21:41
@VerteDinde
VerteDinde merged commit 2e032d6 into main Jun 28, 2026
14 checks passed
@VerteDinde
VerteDinde deleted the fix/reset-signtool-undefined-path branch June 28, 2026 04:03
@electron-npm-package-publisher

Copy link
Copy Markdown

🎉 This PR is included in version 5.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants