Skip to content

perf: optimize version checks and fix offline hang#331

Open
luigimasdea wants to merge 5 commits intoneutralinojs:mainfrom
luigimasdea:fix/version-check-timeout
Open

perf: optimize version checks and fix offline hang#331
luigimasdea wants to merge 5 commits intoneutralinojs:mainfrom
luigimasdea:fix/version-check-timeout

Conversation

@luigimasdea
Copy link
Copy Markdown

@luigimasdea luigimasdea commented Feb 20, 2026

I was looking into the offline hang issue reported in #319. I saw that #320 attempts to fix it by adding a timeout, but it still relies on spawning a child_process.exec('npm view ...').

While a timeout fixes the infinite freeze, spawning a full npm child process is still very heavy and blocks the neu version command execution for a significant amount of time, even when the user is completely online.

Key Changes:

  1. Removed child_process overhead: Replaced the npm view execution in src/utils.js with a lightweight https.get request directly to the npm registry API.
  2. Concurrent network requests: Refactored src/commands/version.js to fetch the global, binary, and client library versions concurrently using Promise.all().
  3. Offline handling: Added a 2-second timeout and proper .catch()/error handling to both checkLatestVersion (src/utils.js) and getRemoteLatestVersion (src/modules/downloader.js). If the network drops or is unreachable, the CLI instantly falls back to printing only the local versions without hanging.
  4. Fixed false (latest) tags: Corrected the display logic. Previously, network failures defaulted to showing the (latest) tag. Now, offline states are handled as null and the CLI won't print false information.

Testing:

I ran the test suite locally, and all tests (including spec/misc.spec.js) pass successfully.

Closes #319

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] 'neu version' hangs indefinitely in offline or restricted network environments

1 participant