Skip to content

Disable npm update-notifier during module-load version check#69769

Open
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-59520
Open

Disable npm update-notifier during module-load version check#69769
ggiesen wants to merge 1 commit into
saltstack:3006.xfrom
ggiesen:fix-59520

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

salt/modules/npm.py runs npm --version from _check_valid_version(), which is invoked by __virtual__() at module-load time whenever an npm binary is on PATH. npm's update-notifier tries to reach the registry on that call; behind a corporate firewall or proxy that blocks it, the command hangs for roughly three minutes before timing out, stalling every salt-call regardless of whether the npm module is actually used.

This passes env={"NO_UPDATE_NOTIFIER": "1"} to that cmd.run call so the version check returns immediately. The change is purely additive and does not alter the version-gating logic.

What issues does this PR fix or reference?

Fixes #59520

Previous Behavior

Any command that loads execution modules (even ones unrelated to npm) blocked for about three minutes when an npm binary was present and the npm registry was unreachable, because _check_valid_version() ran npm --version with the update-notifier enabled.

New Behavior

_check_valid_version() runs npm --version with NO_UPDATE_NOTIFIER=1, so npm skips the registry check and the command returns immediately. Module load is no longer delayed behind a firewall/proxy.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

  • Docs - n/a (no user-facing interface or behaviour change to document)
  • Changelog - changelog/59520.fixed.md
  • Tests written/updated - tests/pytests/unit/modules/test_npm.py:
    • test_check_valid_version_disables_update_notifier_59520 asserts the version check passes env={"NO_UPDATE_NOTIFIER": "1"} (fails without the fix)
    • test_check_valid_version_raises_on_old_npm_59520 (inverse) confirms the version gate still raises on npm < 1.2
    • test_check_valid_version_accepts_recent_npm_59520 confirms a valid version returns without error

Commits signed with GPG?

No

npm.py runs `npm --version` from _check_valid_version(), which is called
by __virtual__() at module-load time whenever an npm binary is on PATH.
npm's update-notifier tries to reach the registry, and behind a firewall
or proxy that blocks it the command hangs for roughly three minutes,
stalling every salt-call regardless of whether the npm module is used.

Pass NO_UPDATE_NOTIFIER=1 in the command environment so the version check
returns immediately.

Fixes saltstack#59520
@ggiesen ggiesen requested a review from a team as a code owner July 10, 2026 17:55
@charzl charzl self-assigned this Jul 10, 2026
@dwoz dwoz added the test:full Run the full test suite label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants