Skip to content

Improve Electron rebuild error handling#3

Merged
MXASoundNDEv merged 1 commit intomainfrom
codex/improve-error-handling-in-rebuild-electron.js
Sep 22, 2025
Merged

Improve Electron rebuild error handling#3
MXASoundNDEv merged 1 commit intomainfrom
codex/improve-error-handling-in-rebuild-electron.js

Conversation

@MXASoundNDEv
Copy link
Copy Markdown
Owner

Summary

  • ensure the Electron rebuild script reports non-zero exit codes with detailed error output
  • fall back to the local cmake-js binary when npx is missing on POSIX hosts
  • document the stricter failure reporting for developers in the Electron README section

Testing

  • npm run lint

https://chatgpt.com/codex/tasks/task_e_68cd69fef21c83248d77943bb7a3b2ea

Copilot AI review requested due to automatic review settings September 22, 2025 08:16
@MXASoundNDEv MXASoundNDEv merged commit a36767c into main Sep 22, 2025
1 check passed
@MXASoundNDEv MXASoundNDEv deleted the codex/improve-error-handling-in-rebuild-electron.js branch September 22, 2025 08:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error handling and robustness of the Electron rebuild script by implementing stricter failure reporting, fallback mechanisms for missing npx, and enhanced error output formatting.

  • Enhanced error handling with detailed error messages and proper exit codes
  • Added fallback to local cmake-js binary when npx is unavailable on POSIX systems
  • Updated documentation to reflect the stricter failure reporting behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/rebuild-electron.js Complete rewrite of rebuild logic with improved error handling, fallback mechanisms, and structured command execution
README.md Added documentation about stricter failure reporting and npx fallback behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const version = process.argv[2] || process.env.ELECTRON_VERSION || process.env.npm_config_target;
if (!version) {
console.error('[soem-node] Veuillez fournir la version d\'Electron (ex: 30.0.0).');
console.error("[soem-node] Veuillez fournir la version d'Electron (ex: 30.0.0).");
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

[nitpick] The quote character has been changed from a backtick to a straight quote, which may cause display inconsistency. Consider keeping the original quote style for consistency.

Suggested change
console.error("[soem-node] Veuillez fournir la version d'Electron (ex: 30.0.0).");
console.error(`[soem-node] Veuillez fournir la version d'Electron (ex: 30.0.0).`);

Copilot uses AI. Check for mistakes.
? ['rebuild', '--runtime=electron', `--runtimeVersion=${version}`, '--loglevel=verbose']
: ['cmake-js', 'rebuild', '--runtime=electron', `--runtimeVersion=${version}`, '--loglevel=verbose'];
const spawnOptions = {
stdio: 'pipe',
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Using 'pipe' stdio mode and then manually piping output may be less efficient than using 'inherit' for real-time output streaming, especially for long-running cmake operations.

Copilot uses AI. Check for mistakes.
}

const npxArgs = ['cmake-js', 'rebuild', ...sharedArgs];
let result = execute('npx', npxArgs);
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable 'result' is reassigned in the fallback logic (line 87), which could make the code harder to follow. Consider using different variable names for clarity.

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +95
let result = execute('npx', npxArgs);

if (result.error?.code === 'ENOENT') {
console.warn("[soem-node] 'npx' est indisponible, tentative avec le binaire local cmake-js.");
const directArgs = ['rebuild', ...sharedArgs];
result = execute(localBinary, directArgs);
if (result.error || result.status !== 0) {
handleFailure(formatCommand(localBinary, directArgs), result);
}
process.exit(0);
}

if (result.error || result.status !== 0) {
handleFailure(formatCommand('npx', npxArgs), result);
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable 'result' is reassigned in the fallback logic (line 87), which could make the code harder to follow. Consider using different variable names for clarity.

Suggested change
let result = execute('npx', npxArgs);
if (result.error?.code === 'ENOENT') {
console.warn("[soem-node] 'npx' est indisponible, tentative avec le binaire local cmake-js.");
const directArgs = ['rebuild', ...sharedArgs];
result = execute(localBinary, directArgs);
if (result.error || result.status !== 0) {
handleFailure(formatCommand(localBinary, directArgs), result);
}
process.exit(0);
}
if (result.error || result.status !== 0) {
handleFailure(formatCommand('npx', npxArgs), result);
let npxResult = execute('npx', npxArgs);
if (npxResult.error?.code === 'ENOENT') {
console.warn("[soem-node] 'npx' est indisponible, tentative avec le binaire local cmake-js.");
const directArgs = ['rebuild', ...sharedArgs];
const directResult = execute(localBinary, directArgs);
if (directResult.error || directResult.status !== 0) {
handleFailure(formatCommand(localBinary, directArgs), directResult);
}
process.exit(0);
}
if (npxResult.error || npxResult.status !== 0) {
handleFailure(formatCommand('npx', npxArgs), npxResult);

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants