Skip to content

Fix: Add retry limit and signal handlers to prevent Electron hang#324

Open
upendra512 wants to merge 1 commit intoAOSSIE-Org:mainfrom
upendra512:fix/electron-server-hang-312
Open

Fix: Add retry limit and signal handlers to prevent Electron hang#324
upendra512 wants to merge 1 commit intoAOSSIE-Org:mainfrom
upendra512:fix/electron-server-hang-312

Conversation

@upendra512
Copy link

Description

Fixes Issue #312 - Electron hangs forever if Nitro server fails to start

Changes

1. Added Retry Limit to waitForServer

  • Added maxRetries parameter (default 60 attempts = 30 seconds)
  • Added attempts counter to track retry count
  • Rejects promise with descriptive error after max retries
  • Prevents infinite hang when server fails to start

2. Added Error Handling

  • Updated startServer to propagate rejection
  • Added try/catch in app.whenReady() to handle startup failures
  • App gracefully quits with error message instead of hanging

3. Added Signal Handlers

  • Added SIGTERM handler for graceful shutdown
  • Added SIGINT handler for interrupt handling
  • Both handlers properly kill server process before quitting

Testing

  • Tested with working Nitro server - starts normally
  • Tested with missing server file - quits after 30s with error
  • Tested SIGTERM signal - clean shutdown
  • Tested SIGINT (Ctrl+C) - clean shutdown

Technical Details

Before: waitForServer would retry indefinitely every 500ms. If Nitro crashed or failed to start, Electron would hang forever with no feedback to the user.

After: Retries for maximum 30 seconds (60 attempts × 500ms), shows error message, quits gracefully, and properly handles termination signals for clean process shutdown.

Related Issue

Closes #312

Add maxRetries parameter to waitForServer (default 60 attempts = 30s)
to prevent infinite hang when Nitro server fails to start. The app now
gracefully quits with an error message instead of hanging forever.

Also add SIGTERM and SIGINT handlers for clean shutdown, ensuring the
server process is properly killed when receiving termination signals.

Fixes AOSSIE-Org#312

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

Warning

Rate limit exceeded

@upendra512 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d7441227-cad5-4678-a390-5b554804ed40

📥 Commits

Reviewing files that changed from the base of the PR and between 25b2382 and fe1a1f1.

📒 Files selected for processing (1)
  • electron/main.cjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can validate your CodeRabbit configuration file in your editor.

If your editor has YAML language server, you can enable auto-completion and validation by adding # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json at the top of your CodeRabbit configuration file.

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.

[Bug]: Electron hangs forever if Nitro server fails to start

2 participants