fix(desktop): recover when the gateway is slow to start instead of stranding the app - #41
Open
ankit-thebigred wants to merge 1 commit into
Conversation
…randing the app waitForReady() threw after a fixed 20s. The throw reached start()'s catch, which scheduled a retry, but start() begins with `if (this.process) return` and the gateway process is still alive at that point, so the retry was a silent no-op. Nothing re-checked the socket afterwards. A gateway that simply needed longer than 20s (schema migration, search index rebuild on a large database) would come up healthy moments later while the window stayed dead until the user quit and relaunched the app. Keep waiting while the process is alive and surface a slow-start notice at the old 20s mark, with a generous hard ceiling as a backstop. Genuine failures are unaffected: the existing 'exit' handler clears this.process, which trips the identity check inside the loop and drives the established restart path. Adds an optional onSlowStart callback so the UI can tell the user startup is still in progress rather than showing nothing.
|
@ankit-thebigred is attempting to deploy a commit to the DevApe Team on Vercel. A member of the Team first needs to authorize it. |
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.
Found while fixing #37. No issue filed for this one.
The problem
waitForReady()gives up after a fixed 20s and throws. The interesting part is what happens next.The throw reaches
start()'s catch block, which incrementsretriesand schedulessetTimeout(() => this.start(), 1000). Butstart()opens with:On a readiness timeout the gateway process is still alive, so
this.processis still set and the retry returns immediately without doing anything. It is a silent no-op. Nothing re-checks the socket afterwards, and because no exception is thrown the second time, the retry counter stops advancing andonErroris never reached either.The result is that a gateway which simply needed longer than 20s comes up healthy moments later and the desktop never notices. The window stays dead until the user quits and relaunches the whole app.
This is reachable through ordinary slow startup work: a schema migration, or a search index rebuild on a large database. Before #37 is fixed, that rebuild happens on every launch, so the two bugs compound into an app that cannot start at all.
The fix
Treat "slow" and "failed" as different things.
onSlowStartcallback once, so the UI can say startup is still in progress instead of showing nothing.Genuine failures are unaffected and still take the existing path: the
exithandler clearsthis.process, which trips thethis.process !== procidentity check already inside the loop, which throws and drives the established restart logic.onSlowStartis optional, so no caller has to change.Verification
cd desktop && npm run typecheckreports 0 errors, identical to themainbaseline.Note
Raising the 20000 constant is the obvious workaround and it does help, but it only moves the cliff. The reason the app never recovers is the no-op retry, so that is what this addresses.