Repository navigation
fix: reliable self-update restart (v7.5.2) - #233
Merged
Merged
Conversation
The "Update Now" flow installed the new version but then died without
coming back up — the port was freed but nothing relistened, so the UI
kept showing the stale version and the page failed to reload.
Root cause: the restart spawned a child inside a `process.on('exit')`
handler. The event loop is already draining at exit time, so the
detached child frequently never survived.
Fix: spawn a fully-detached, unref'd restarter (own process group,
stdio ignored) BEFORE exiting, then exit after a short tick to release
the port. Restarter reuses the same port/host and skips reopening the
browser. Also raise the npm-install timeout 60s -> 120s.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Clicking Update Now installed the new version via
npm i -g codbash-app@latest, but the server then died and never came back up — the port was freed yet nothing relistened. The UI kept showing the stale version (v7.4.0 → v7.5.1) and the autolocation.reload()hit a dead server.Root cause
/api/updatespawned the restarter inside aprocess.on('exit')handler:At exit time the event loop is already draining — spawning there is unreliable and the detached child frequently never survives. Net result: server gone, no relisten.
Fix
detached: true,stdio: 'ignore', own process group,.unref()) before exiting, thenprocess.exit(0)after a 250ms tick so the port is released for the restarter.--port/--hostand passes--no-browser(the existing tab reloads itself — no duplicate window).argv[1]path npm just overwrote.Version
Patch bump
7.5.1→7.5.2+ changelog entry.Testing
node -csyntax check passes onserver.jsandchangelog.js.7.5.2.🤖 Generated with Claude Code