Skip to content

feat: support delaying installation of recently published npm packages#24334

Merged
Artur- merged 11 commits into
mainfrom
npm-install-delay
May 14, 2026
Merged

feat: support delaying installation of recently published npm packages#24334
Artur- merged 11 commits into
mainfrom
npm-install-delay

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 13, 2026

Adds a minimum package age check (default disabled) so that npm, pnpm and bun are instructed not to install package versions newer than the configured threshold. This mitigates supply-chain attacks where a compromised version is briefly published to the registry.

The threshold is exposed via Options#withMinimumPackageAgeDays(int); setting it to 0 disables the check.

Artur- added 3 commits May 13, 2026 10:26
Adds a minimum package age check (default 2 days) so that npm, pnpm and
bun are instructed not to install package versions newer than the
configured threshold. This mitigates supply-chain attacks where a
compromised version is briefly published to the registry.

The threshold is exposed via Options#withMinimumPackageAgeDays(int);
setting it to 0 disables the check.
Surfaces the new minimum-package-age option through the Vaadin Maven
plugins so it can be configured per project or via the
-Dvaadin.npm.minimumPackageAgeDays=<days> system property. Defaults to
2 days; set to 0 to disable.
pnpm exposes minimumReleaseAge as a setting rather than a top-level CLI
option, so it has to be set through the --config.<name>=<value> form
(matching how --config.node-linker=hoisted is already passed). The
previous form caused pnpm to fail with "Unknown option:
'minimum-release-age'" during the production bundle build.
@knoobie
Copy link
Copy Markdown
Contributor

knoobie commented May 13, 2026

While I'm a total fan of this.. how can I use the latest vaadin version with it? e.g. 25.2.1 got released and I wanna use it the same day? :(

@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 13, 2026

What if that npm package was hijacked and nobody has noticed it yet?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Test Results

 1 408 files  ±0   1 408 suites  ±0   1h 22m 17s ⏱️ -19s
10 150 tests ±0  10 080 ✅ ±0  70 💤 ±0  0 ❌ ±0 
10 625 runs  ±0  10 546 ✅ ±0  79 💤 ±0  0 ❌ ±0 

Results for commit 77ddfea. ± Comparison against base commit 2e3d63f.

♻️ This comment has been updated with latest results.

@Legioth
Copy link
Copy Markdown
Member

Legioth commented May 13, 2026

how can I use the latest vaadin version with it?

The only thing you can do is to change the configuration to 0 days. npm doesn't have an option to use different rules for different packages and that does makes sense since it would be hypocritical of us to assert that we would be immune to these types of attacks.

The core question though is whether users will understand what goes on if they try to update to a new Vaadin version on the day it's released?

@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 13, 2026

If we do this, we should always release the web components 2 days before the rest

@knoobie
Copy link
Copy Markdown
Contributor

knoobie commented May 13, 2026

The core question though is whether users will understand what goes on if they try to update to a new Vaadin version on the day it's released?

The typical flow user won't understand it.. and complains...

If we do this, we should always release the web components 2 days before the rest

Sounds like a good trade-off!

@Artur- Artur- changed the title feat: delay installation of recently published npm packages feat: support delaying installation of recently published npm packages May 14, 2026
@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 14, 2026

Let's tune this PR to only add the possibility and make a followup PR for setting a default. Maybe 1 day would be a reasonably compromise on the default - the recent tanstack case was detected in less than an hour

The 2-day default blocks legitimate same-day Vaadin platform upgrades
because npm has no per-package exclusion mechanism (tracked upstream in
npm/cli#8979). Default the option to 0 (disabled) until that lands; the
flag stays in place so users and CI can opt in for testing.
@Artur- Artur- requested a review from mcollovati May 14, 2026 08:04
Without this, Gradle users would silently fall back to the default
method on PluginAdapterBuild and have no way to change or disable the
minimum-package-age check from the vaadin {} DSL or via
-Pvaadin.npm.minimumPackageAgeDays=N.
Copy link
Copy Markdown
Collaborator

@mcollovati mcollovati left a comment

Choose a reason for hiding this comment

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

I did not test it yet, but I added a bunch of comments.

Also, --config.minimum-release-age was added in pnpm 10.16.0; in Flow DEFAULT_PNPM_VERSION is 11.0.8, so it is fine, but we have SUPPORTED_PNPM_VERSION 7.0. Should we upgrade this value?
Similar for bun, we have SUPPORTED_BUN_VERSION 1.0.6, but is --minimum-release-age supported on that version?

Comment thread flow-build-tools/src/main/java/com/vaadin/flow/server/frontend/Options.java Outdated
Comment thread flow-server/src/main/java/com/vaadin/flow/server/InitParameters.java Outdated
Artur- added 2 commits May 14, 2026 10:19
Per @mcollovati's review:

- Rename the option to minimumFrontendPackageAgeDays everywhere (Options
  field+accessors, PluginAdapterBuild method, InitParameters constant
  and value, Maven and Gradle parameter name) so the term is unambiguous
  outside JavaScript-only contexts.
- Move the Maven @parameter from FlowModeAbstractMojo to BuildFrontendMojo
  (and BuildDevBundleMojo), since only those two mojos implement
  PluginAdapterBuild and actually run the install.
- Fix Gradle plugin convention to default 0 (matching Maven) instead of 1.
- Mention bun (alongside npm and pnpm) in field/setter/helper Javadoc;
  drop the stale "bun does not support" comment.
- Document the minimum tool versions required for the per-tool flag
  (pnpm >= 10.16.0, bun >= 1.3.0).
- Drop the redundant pnpm "override value" test that only varied by day
  count from the existing pnpm test.
… to 1.3.0

These are the first versions that support the minimumReleaseAge setting
(pnpm) and --minimum-release-age flag (bun) used by the new
minimumFrontendPackageAgeDays option. Older tool versions would fail
the install with "unknown option" once the option is enabled.

DEFAULT_PNPM_VERSION (11.0.8) is already above the new minimum, so no
managed-pnpm change is needed.
@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 14, 2026

bumped SUPPORTED_PNPM_VERSION to 10.16 and SUPPORTED_BUN_VERSION to 1.3.0

mcollovati and others added 2 commits May 14, 2026 13:51
- Document IllegalArgumentException via @throws on
  Options#withMinimumFrontendPackageAgeDays.
- Add vaadin.npm.minimumFrontendPackageAgeDays to
  DeprecatedPropertyResolver.NOT_MIGRATED so the resolver doesn't try
  to look up a non-prefixed legacy form for this brand-new property.
@Artur- Artur- requested a review from mcollovati May 14, 2026 12:20
@sonarqubecloud
Copy link
Copy Markdown

@Artur- Artur- enabled auto-merge May 14, 2026 12:31
@mcollovati
Copy link
Copy Markdown
Collaborator

Running the maven plugin from this branch on the spring skeleton gives me errors if I use pnpm and vaadin.npm.minimumFrontendPackageAgeDays greater than 1 (with 0 or 1 the build completes successfully).
However, I don't understand if this is expected or not

[ERROR] Command `/home/marco/.nvm/versions/node/v24.11.0/bin/node /home/marco/.nvm/versions/node/v24.11.0/bin/../lib/node_modules/npm/bin/npx-cli.js --yes --quiet pnpm@11.0.8 --config.node-linker=hoisted --ignore-scripts install --no-frozen-lockfile --config.minimum-release-age=14400` failed:
npm warn Unknown project config "node-linker". This will stop working in the next major version of npm.
npm warn Unknown project config "shamefully-hoist". This will stop working in the next major version of npm.
npm warn Unknown project config "strict-peer-dependencies". This will stop working in the next major version of npm.
Progress: resolved 1, reused 0, downloaded 0, added 0
[ERR_PNPM_MISSING_TIME] The metadata of @babel/plugin-transform-react-jsx-development is missing the "time" field

This error happened while installing a direct dependency of /tmp/skeleton-starter-flow-spring

If you cannot fix this registry issue, then set "resolution-mode" to "highest".

@mcollovati
Copy link
Copy Markdown
Collaborator

Now I deleted the pnpm cache and I get the following error, so maybe it's expected because of snapshot usage?

[ERR_PNPM_NO_MATURE_MATCHING_VERSION] Version 25.2.0-alpha12 (released 29 hours ago) of @vaadin/aura does not meet the minimumReleaseAge constraint

This error happened while installing a direct dependency of /tmp/skeleton-starter-flow-spring

The latest release of @vaadin/aura is "25.1.3". Published at 5/11/2026

Other releases are:
  * next: 25.2.0-alpha12 published at 5/13/2026

If you need the full list of all 62 published versions run "pnpm view @vaadin/aura versions".

If you want to install the matched version ignoring the time it was published, you can add the package name to the minimumReleaseAgeExclude setting. Read more about it: https://pnpm.io/settings#minimumreleaseageexclude

@mcollovati
Copy link
Copy Markdown
Collaborator

mcollovati commented May 14, 2026

OK, after deleting the pnpm cache and using Vaadin stable + Flow snapshot, the error is gone.
The build fails if I set, for example, -Dvaadin.npm.minimumFrontendPackageAgeDays=12 but this should be fine,

@mcollovati
Copy link
Copy Markdown
Collaborator

Seems to work fine with bun as well.

@Artur- Artur- added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit 6ea0129 May 14, 2026
31 checks passed
@Artur- Artur- deleted the npm-install-delay branch May 14, 2026 13:13
@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 14, 2026

There is a pnpm issue about that ”time” error and apparently it has been fixed two or three times already.. something to do with the pnpm cache

@vaadin-bot
Copy link
Copy Markdown
Collaborator

Hi @Artur- and @Artur-, when i performed cherry-pick to this commit to 25.1, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 6ea0129
error: could not apply 6ea0129... feat: support delaying installation of recently published npm packages (#24334)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

Artur- added a commit that referenced this pull request May 15, 2026
#24334) (CP: 25.1) (#24348)

Adds a minimum package age check (default disabled) so that npm, pnpm
and bun are instructed not to install package versions newer than the
configured threshold. This mitigates supply-chain attacks where a
compromised version is briefly published to the registry.

The threshold is exposed via Options#withMinimumPackageAgeDays(int);
setting it to 0 disables the check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants