Skip to content

Close EE on every Quit and keep reconnecting after a switch restart - #46

Merged
Views2k merged 2 commits into
mainfrom
fix/quit-and-reconnect
Nov 18, 2026
Merged

Views2k merged 2 commits into
mainfrom
fix/quit-and-reconnect

Conversation

@Views2k

@Views2k Views2k commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

After a switch restart, EE logged "lost the switch" and did not reconnect for the 36 minutes before it was restarted, and Quit from the tray left EE running.

Quit

When Quit could not confirm that the switch lighting was returned, EE stayed open and asked for a second Quit, which then waited for four more gateway cleanup attempts before ending the service.

  • Every Quit closes EE. The window hides at once and the tray icon stays until the service has stopped.
  • The desktop makes one workspace close attempt. If it is not confirmed, ServiceHost writes exit to the gateway and waits up to 15 seconds before ending the process tree. The unconfirmed exit is recorded in last-session.json, so the next start recovers the lighting.
  • On exit the gateway makes no further release attempt: it tells the engine to quit, closes private and LAN access, and exits within 10 seconds. Closing its input without exit still starts the four-attempt cleanup used after a desktop crash.

Reconnect

  • Connection errors retry for as long as the engine runs, with the delay growing to one minute. The five-attempt limit is removed.
  • A connection lost during a write leaves output unconfirmed. The engine used to wait for Reconnect switch in that case. It now runs the same recovery automatically on the same schedule, and resumes lighting only if it was running before the loss.
  • For 10 minutes after a lost connection, a switch that answers SSH before its lighting is ready (missing per-port lighting, an unverified daemon or a LightingCapabilityError during recovery) is retried as a switch that is still starting.
  • A rejected login, a changed SSH key and a changed ownership record still stop the attempts and set reconnect_required.

Verification

  • Python: 2,903 tests passed; ruff check clean.
  • JavaScript: 880 passed, 0 failed.
  • Desktop checks: --quit-check (confirmed, refused then exited, refused and unresponsive) and --service against the simulator, 1,987 checks passed.
  • The real gateway in demo mode exited with code 1 about 250 ms after exit, and both engine processes ended.
  • New tests cover retries past five attempts with a capped delay, automatic recovery with and without resuming, a changed key or ownership record stopping recovery, the startup window and its expiry, and stop() not waiting for an automatic attempt.
  • Not tested against a physical switch restart.

Quit kept EE open when it could not confirm that the switch lighting was
returned, for example while the switch restarted, and a second Quit waited
for four more gateway attempts. Every Quit now hides the window at once and
makes one close attempt. When that is not confirmed, the desktop sends
"exit" to the gateway, which closes private and LAN access, tells the engine
to quit and exits within 10 seconds; the unconfirmed exit is recorded so the
next start recovers the lighting.

The engine stopped reconnecting after five failures, about a minute, and a
connection lost during a write waited for Reconnect switch. Connection
errors now retry for as long as the engine runs, with the delay capped at a
minute. Output that a lost connection left unconfirmed is recovered with the
same steps as Reconnect switch once the switch answers, and lighting resumes
only if it was running. For 10 minutes after a lost connection, a switch
that answers before its lighting is ready is retried too. A rejected login,
a changed SSH key or a changed ownership record still stops the attempts.
@Views2k
Views2k merged commit 781bfcb into main Nov 18, 2026
3 checks passed
@Views2k
Views2k deleted the fix/quit-and-reconnect branch November 18, 2026 04:49
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.

1 participant