Skip to content

[BUG] npm ping does respond with pong even if there is no internet connection #4112

Closed
@kobL

Description

@kobL

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

The npm ping command does not work like expected. If there is a internet connection, I get a pong in <1 second like expected.

If I disconnect myself from the internet, I still get a pong always after around 70 seconds +/- 100ms. This is not the documented and expected behaviour.

This worked in npm v 6~. We have this command in a build script to check the connection to the npm registry. Sadly, we do not have an automated test for offline situation, so it took us very long to discover this.

Expected Behavior

I expect the npm ping command to fail if there is no internet connection.

Steps To Reproduce

  1. In this environment: Latest LTS node/npm version on Windows Server 2019 without a internet connection
  2. With this config: default config
  3. Run 'npm ping'
  4. See error: Pong after 70 s +/- 100ms

Here a screenshot from my System:
First ping was without internet connection, second one with.
image

Environment

  • npm: 8.1.4
  • Node: v16.13.1
  • OS: Windows Server 2019 1809 Build 17763.107
  • platform: VMWare Player running on
  • npm config:
    $ npm config ls
    ; "builtin" config from C:\Program Files (x86)\nodejs\node_modules\npm\npmrc

prefix = "C:\Users\Operator\AppData\Roaming\npm"

; "global" config from C:\Users\Operator\AppData\Roaming\npm\etc\npmrc

; strict-ssl = false ; overridden by user
; update-notifier = false ; overridden by user

; "user" config from C:\Users\Operator.npmrc

//pkgs.dev.azure.com/xxx/_packaging/xxx-external/npm/registry/:_password = (protected)
//pkgs.dev.azure.com/xxx/_packaging/xxx-external/npm/registry/:email = "not-used@example.com"
//pkgs.dev.azure.com/xxx/_packaging/xxx-external/npm/registry/:username = "VssSessionToken"
//pkgs.dev.azure.com/xxx/_packaging/xxx-internal/npm/registry/:_password = (protected)
//pkgs.dev.azure.com/xxx/_packaging/xxx-internal/npm/registry/:email = "not-used@example.com"
//pkgs.dev.azure.com/xxx/_packaging/xxx-internal/npm/registry/:username = "VssSessionToken"
registry = "https://registry.npmjs.org/"
strict-ssl = false
update-notifier = false

; node bin location = C:\Program Files (x86)\nodejs\node.exe
; cwd = C:\Program Files\Git
; HOME = C:\Users\Operator
; Run npm config ls -l to show all defaults.

; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions