Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodemon hangs if started without internet connection #2096

Closed
davidhusz opened this issue Jan 16, 2023 · 15 comments
Closed

Nodemon hangs if started without internet connection #2096

davidhusz opened this issue Jan 16, 2023 · 15 comments
Labels
not a bug / external to nodemon An issue that is outside of nodemon

Comments

@davidhusz
Copy link

  • Versions: node@v16.18.1, linux@5.15.0-56-generic
  • nodemon -v: 2.0.20
  • Operating system/terminal environment (powershell, gitshell, etc): fish on gnome-terminal on ubuntu
  • Using Docker? What image: no
  • Command you ran: npx nodemon server.js

Expected behaviour

When I run npx nodemon server.js while connected to the internet, the server starts up as expected, preceded by nodemon printing its info messages. When I run the same without an internet connection, I expect it to behave the same.

Actual behaviour

When starting nodemon without an internet connection, the program hangs indefinitely, without printing anything to the terminal. This happens even when just running nodemon --help.

Steps to reproduce

  1. Disconnect your internet
  2. Invoke nodemon

nodemon --dump:

{
  run: false,
  required: false,
  timeout: 1000,
  options: {
    dump: true,
    ignore: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**',
      re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
    ],
    watch: [ '*.*', re: /.*\..*/ ],
    monitor: [
      '*.*',
      '!**/.git/**',
      '!**/.nyc_output/**',
      '!**/.sass-cache/**',
      '!**/bower_components/**',
      '!**/coverage/**',
      '!**/node_modules/**'
    ],
    ignoreRoot: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**'
    ],
    restartable: 'rs',
    colours: true,
    execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
    stdin: true,
    runOnChangeOnly: false,
    verbose: false,
    signal: 'SIGUSR2',
    stdout: true,
    watchOptions: {},
    execOptions: {
      script: 'server.js',
      exec: 'node',
      args: [],
      scriptPosition: 0,
      nodeArgs: undefined,
      execArgs: [],
      ext: 'js,mjs,json',
      env: {}
    }
  },
  load: [Function (anonymous)],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: {
    raw: { executable: 'node', args: [ 'server.js' ] },
    string: 'node server.js'
  }
}
@remy
Copy link
Owner

remy commented Jan 16, 2023 via email

@github-actions
Copy link

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@github-actions github-actions bot added the stale no activity for 2 weeks label Jan 30, 2023
@sam-b-slingshot
Copy link

I'm bumping this ^^

@github-actions github-actions bot removed the stale no activity for 2 weeks label Feb 8, 2023
@remy remy added bug confirmed bug not-stale Tell stalebot to ignore this issue labels Feb 8, 2023
@nejclovrencic
Copy link

I think this is an issue with npx and not nodemon itself. npx tries to check for the latest version before running the package, and the network call fails:

DEBUG=* npx nodemon index.js
  agentkeepalive sock[0#registry.npmjs.org:443::::::::true:::::::::::::] create, timeout 300001ms +0ms
  agentkeepalive sock[0#registry.npmjs.org:443::::::::true:::::::::::::](requests: 1, finished: 0) error: Error: getaddrinfo ENOTFOUND registry.npmjs.org
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'registry.npmjs.org'
}, listenerCount: 2 +5ms

@remy
Copy link
Owner

remy commented Feb 13, 2023

I think this is nodemon itself through the update check. It needs to have either a timeout or a safeguard (I know that try/catch doesn't particularly work).

@nejclovrencic
Copy link

It only happens to me if I don't have nodemon installed globally, thus I suspected npx. There are also other similar issues reported there, such as npm/cli#6157. If I install nodemon globally and disconnect the internet, it seems to work fine.

@remy
Copy link
Owner

remy commented Feb 14, 2023 via email

@davidhusz
Copy link
Author

I just tried out what @nejclovrencic mentioned and can confirm that the bug also only happens for me when nodemon is not installed globally. Interestingly, as long as it's installed globally it works both when invoking it via nodemon as well as via npx nodemon.

@DKdev117
Copy link

can you assign this issue to me?

I will try to solve this issue.

@remy
Copy link
Owner

remy commented Oct 3, 2023

@DKdev117 doesn't need to be assigned, you can create a PR (ideally with tests)

@DKdev117
Copy link

DKdev117 commented Oct 4, 2023

@remy Ok sir thank you

@iamabhshk
Copy link

Is this issue resolved?

@remy
Copy link
Owner

remy commented Jan 6, 2024

@iamabhshk no - have you seen it lately or are you just asking (because you want to fix it)?

@iamabhshk
Copy link

@remy I mean I just checked from my end but couldn't see such behavior which was mentioned by @davidhusz
So just curious if its fixed, if not I would like to have a look at it

@remy remy added not a bug / external to nodemon An issue that is outside of nodemon and removed bug confirmed bug not-stale Tell stalebot to ignore this issue labels Jan 7, 2024
@remy
Copy link
Owner

remy commented Jan 7, 2024

Finally got around to giving this a proper test. It's actually just npx that is the issue.

You get the same behaviour if you disconnect from the web and run any other npx xxx command that can't be loaded from a parent directory (which is why npx nodemon works when you have nodemon installed globally).

Try the following (assuming you don't have enhance globally):

npx "@enhance/cli@latest" new ./myproject -y

It's hang in the same way.

I suggest @davidhusz raise this (in a non-nodemon specific way) with npm 👍

@remy remy closed this as completed Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug / external to nodemon An issue that is outside of nodemon
Projects
None yet
Development

No branches or pull requests

6 participants