Skip to content

fix: handle offline/network errors in version command#433

Open
Swastik-Prakash1 wants to merge 1 commit intoneutralinojs:mainfrom
Swastik-Prakash1:fix/version-command-offline-crash
Open

fix: handle offline/network errors in version command#433
Swastik-Prakash1 wants to merge 1 commit intoneutralinojs:mainfrom
Swastik-Prakash1:fix/version-command-offline-crash

Conversation

@Swastik-Prakash1
Copy link
Copy Markdown

  • Add 5s timeout to checkLatestVersion to prevent hang when npm registry is unreachable
  • Guard against null versionInfo to prevent TypeError crash
  • Fix double resolve() call in checkLatestVersion promise
  • Wrap getRemoteLatestVersion calls in version.js with try/catch to handle network failures gracefully
  • Show '(offline)' indicator when version check is unavailable

Fixes: network error handling in neu version command

- Add 5s timeout to checkLatestVersion to prevent hang when npm
  registry is unreachable
- Guard against null versionInfo to prevent TypeError crash
- Fix double resolve() call in checkLatestVersion promise
- Wrap getRemoteLatestVersion calls in version.js with try/catch
  to handle network failures gracefully
- Show '(offline)' indicator when version check is unavailable

Fixes: network error handling in neu version command
Signed-off-by: Swastik Prakash <swastikprakashofficial@gmail.com>
@Swastik-Prakash1
Copy link
Copy Markdown
Author

Problem

When the user is offline or the npm registry is unreachable, neu version crashes with:
TypeError: Cannot read properties of null (reading 'trim')

Additionally, the command hangs indefinitely waiting for npm to respond.

A secondary issue: getRemoteLatestVersion in version.js was called without any
error handling, causing unhandled promise rejections when GitHub API is unreachable.

Changes

  • src/utils.js: Added a 5-second timeout to checkLatestVersion to prevent hanging
  • src/utils.js: Added null/error guard before calling .trim() on npm output
  • src/utils.js: Fixed double resolve() call in the promise
  • src/commands/version.js: Wrapped getRemoteLatestVersion calls in try/catch
  • src/commands/version.js: Show (offline) indicator when version check unavailable

Testing

Tested by disconnecting network and running neu version — command now completes
gracefully with a warning instead of crashing.

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.

1 participant