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

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

Closed
2 tasks done
kobL opened this issue Dec 2, 2021 · 1 comment
Closed
2 tasks done
Labels
Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release

Comments

@kobL
Copy link

kobL commented Dec 2, 2021

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
@kobL kobL added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Dec 2, 2021
@kobL kobL changed the title [BUG] npm ping does respond with pong even if there is no network connection [BUG] npm ping does respond with pong even if there is no internet connection Dec 2, 2021
@nlf nlf removed the Needs Triage needs review for next steps label Oct 3, 2022
@nlf
Copy link
Contributor

nlf commented Oct 3, 2022

confirmed as a bug

notes for fixing:
the problem is that npm-registry-fetch sees the ?write=true flag and sets the cache mode to no-cache which sounds correct, but the semantics for that mode allow stale responses in the event that the revalidation request fails. we don't want to allow stale responses here, so what we actually need is a mode of no-store. we'll need to either add a --online flag to the cli that maps to no-store or we'll need to patch npm-registry-fetch to detect this case (probably using the ?write=true query param) and sets the mode there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants