fix: make update check non-blocking by spawning detached child process#246
Draft
bukinoshita wants to merge 3 commits intomainfrom
Draft
fix: make update check non-blocking by spawning detached child process#246bukinoshita wants to merge 3 commits intomainfrom
bukinoshita wants to merge 3 commits intomainfrom
Conversation
When the update-state cache is stale or missing, the CLI now spawns a detached child process to refresh the cache in the background instead of awaiting a fetch() in the main process. This prevents commands from appearing to hang for up to 5 seconds on slow or offline networks. Key changes: - checkForUpdates() is now synchronous; it reads cached state, shows any stale notice, and kicks off a detached node process to refresh - buildRefreshScript() generates a self-contained Node script that fetches the latest version and writes update-state.json, writing the current version as fallback on any failure (prevents repeated retries on every command) - spawnBackgroundRefresh() spawns the script detached with stdio ignored and unrefs the child so the main process exits immediately - All functions converted to const arrow functions per coding standards - Removed JSDoc comments per coding standards Resolves BU-642 Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Member
Author
|
@cubic-dev-ai can you review? |
Contributor
@bukinoshita I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/update-check.ts">
<violation number="1" location="src/lib/update-check.ts:30">
P2: Falling back to `'node'` disables background update refresh for standalone binary installs that do not have Node in PATH.</violation>
</file>
<file name="src/cli.ts">
<violation number="1" location="src/cli.ts:189">
P2: Wrap `checkForUpdates()` in a local guard; it can still throw on malformed cached state and currently bubbles into the global error handler.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Member
Author
|
@cursor fix conflicts |
|
Resolved all merge conflicts with main and addressed both cubic review items:
|
Integrate upstream changes from main (new commands, json skip option, dependency updates) with the non-blocking update check implementation. - Merge UpdateCheckOptions type and json skip into synchronous checkForUpdates - Wrap checkForUpdates() call in try/catch in cli.ts per review feedback - Improve resolveNodePath() to check argv[0] and fall back to execPath for standalone binary installs without node in PATH - Include new commands: automations, events, listCommands - Rewrite json-option tests for synchronous checkForUpdates Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.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.


Summary by cubic
Make the CLI update check non‑blocking by moving the network fetch to a detached background process. Commands now exit immediately even on slow/offline networks, addressing BU-642.
checkForUpdates()is now synchronous; uses cached state, shows a stale notice if it indicates a newer version, and spawns a background refresh when the cache is stale/missing. Respects--json/--quietto skip the notice.spawnBackgroundRefresh()to runnode -edetached withstdio: 'ignore'and.unref(); spawn failures are ignored so the main process always exits.buildRefreshScript()fetches the latest GitHub release and writesupdate-state.json, writing the current version on any failure or invalid response to avoid repeated retries.resolveNodePath()to preferprocess.execPath, fall back toargv[0], and handle standalone binary installs across platforms.src/cli.ts: callcheckForUpdates()inside atry/catchso the update check is non‑critical.node:child_processspawn; add coverage for background refresh,resolveNodePath, JSON skip behavior, spawn failure handling, and stale notice behavior.Written for commit 6831172. Summary will update on new commits.