Skip to content

fix: allow min-release-age in npmrc to coexist with --before in spawn…#9292

Open
raazkhnl wants to merge 1 commit intonpm:latestfrom
raazkhnl:fix/9291-min-release-age-pacote-spawn
Open

fix: allow min-release-age in npmrc to coexist with --before in spawn…#9292
raazkhnl wants to merge 1 commit intonpm:latestfrom
raazkhnl:fix/9291-min-release-age-pacote-spawn

Conversation

@raazkhnl
Copy link
Copy Markdown

@raazkhnl raazkhnl commented May 1, 2026

…ed subprocesses

When the user has min-release-age=N in their .npmrc, the config flatten function derives a before date used by pacote. Whenever pacote spawns a child npm process (e.g. preparing a git: or github: dep), it forwards --before=<date> to the child. The child then loads the same .npmrc and the previously declared mutual-exclusivity between before and min-release-age caused a hard configuration error.

This makes the two options coexist: the exclusive constraints are removed and both flatten functions resolve to the earlier of the two effective dates, never widening the user's most conservative bound. The min-release-age flatten no longer mutates the per-source config object (the prior obj.before = ... / delete obj['min-release-age'] mutations were vestigial and only masked the conflict at the parent level, not in spawned children).

min-release-age is also added to the params arrays for outdated and update so it remains visible in their command help; it was previously displayed implicitly via the before exclusive grouping.

Fixes: #9291

@raazkhnl raazkhnl requested a review from a team as a code owner May 1, 2026 01:48
@owlstronaut owlstronaut self-assigned this May 1, 2026
Copy link
Copy Markdown
Contributor

@owlstronaut owlstronaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for digging in to this! The fix for the spawn case seems to work great. I'm concerned about the flatten changing precedence though. min-release-age now effectively can't be relaxed by a higher priority source. so npm i --min-release-age=0 will silently get ignored if .npmrc is stricter. I think the PR just needs to be narrowed a bit

…ed subprocesses

When the user has `min-release-age=N` in their `.npmrc`, the config flatten
function derives a `before` date used by pacote. Whenever pacote spawns a
child npm process (e.g. preparing a `git:` or `github:` dep), it forwards
`--before=<date>` to the child. The child then loads the same `.npmrc` and
the previously declared mutual-exclusivity between `before` and
`min-release-age` caused a hard configuration error.

This makes the two options coexist: the `exclusive` constraints are
removed and both flatten functions resolve to the earlier of the two
effective dates, never widening the user's most conservative bound.
The `min-release-age` flatten no longer mutates the per-source config
object (the prior `obj.before = ...` / `delete obj['min-release-age']`
mutations were vestigial and only masked the conflict at the parent
level, not in spawned children).

`min-release-age` is also added to the `params` arrays for `outdated`
and `update` so it remains visible in their command help; it was
previously displayed implicitly via the `before` exclusive grouping.

Fixes: npm#9291
@raazkhnl raazkhnl force-pushed the fix/9291-min-release-age-pacote-spawn branch from 9a10258 to 8daf473 Compare May 2, 2026 01:27
@raazkhnl raazkhnl requested a review from owlstronaut May 2, 2026 06:12
// absolute date overrides a relative window. Across sources, normal
// priority ordering means a higher-priority `before` will overwrite
// this `flatOptions.before` later in the flatten loop.
if (obj['min-release-age'] != null && obj.before == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (obj['min-release-age'] != null && obj.before == null) {
if (obj['min-release-age'] != null && !Object.hasOwn(obj, 'before')) {

this will scope it to the current source so the CLI/env can still override an npmrc-set before

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.

[BUG] npm breaks when using min-release-age and git: or github: urls for dependencies

2 participants