perf: optimize version checks and fix offline hang#331
Open
luigimasdea wants to merge 5 commits intoneutralinojs:mainfrom
Open
perf: optimize version checks and fix offline hang#331luigimasdea wants to merge 5 commits intoneutralinojs:mainfrom
luigimasdea wants to merge 5 commits intoneutralinojs:mainfrom
Conversation
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.
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
npmchild process is still very heavy and blocks theneu versioncommand execution for a significant amount of time, even when the user is completely online.Key Changes:
child_processoverhead: Replaced thenpm viewexecution insrc/utils.jswith a lightweighthttps.getrequest directly to the npm registry API.src/commands/version.jsto fetch the global, binary, and client library versions concurrently usingPromise.all()..catch()/errorhandling to bothcheckLatestVersion(src/utils.js) andgetRemoteLatestVersion(src/modules/downloader.js). If the network drops or is unreachable, the CLI instantly falls back to printing only the local versions without hanging.(latest)tags: Corrected the display logic. Previously, network failures defaulted to showing the(latest)tag. Now, offline states are handled asnulland 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