Repository navigation
Description
Description of the bug
When the postinstall script of the project itself fails, the frontend build as well as the devserver tasks silently ignore this failure.
Expected behavior
The production build task as well as the devserver should fail to proceed, and show the error output produced by the postinstall task.
Minimal reproducible example
Configure a postinstall script that fails, for instance:
{
"scripts": {
"postinstall": "node -e 'console.error(\"failure\"); process.exit(5)'"
},
"...": "..."
}Example with patch-package
In our specific situation, we use the patch-package npm module to work around issues in 3rd party libraries that are not yet (or never will be) accepted upstream.
We use this in postinstall script in our package.json file, as documented for the patch-package module, like so:
{
"...": "...",
"scripts": {
"postinstall": "patch-package --error-on-fail"
},
"....": "..."
}This postinstall script will fail with a non-zero exitcode if the patches we maintain don't cleanly apply anymore. This is a good thing, because then we should investigate how the 3rd-party library changed and whether we have to update or get rid of our patch.
But because the frontend build functionality in the gradle plugin, as well as the dev-server that hot-reloads the frontend bundle, silently ignore this error, we weren't notified of these errors at all.
Code pointer
The problem is caused by TaskRunNpmInstall.java#L396 ignoring the exit code of process.waitFor
That code should inspect the exit code, and if it is non-zero throw an exception. In that case, the output of the process should also be shown on the console. Right now, the output of the process is only logged on the debug level.
Versions
- Vaadin / Flow version: 24.7.5
- Java version: 21
- OS version: any
- Browser version (if applicable): N/A
- Application Server (if applicable): N/A
- IDE (if applicable): N/A
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fields✅ Closed
Activity
totally-not-ai commentedon Sep 17, 2026
Analysis
This is a real bug, and the code pointer in the report is accurate.
Root cause
TaskRunNpmInstallruns the install with--ignore-scriptsand then runs thepostinstallscript of each package in the postinstall list explicitly (the list starts with".", i.e. the project's ownpackage.json, which is thepatch-packagecase here). That explicit run captured the process output into a debug-level log and then calledprocess.waitFor()without looking at the exit code, so a failing script left no trace above debug level and the build/dev server continued with a half-patchednode_modules.There was a second, pnpm-only problem in the same place:
pnpm run postinstallfirst performs itsverify-deps-before-runcheck, which kicks off an install of its own. That install repeats the one Flow just ran but without--ignore-scriptsand without the arguments that exempt Vaadin's own packages from the minimum release age, so on pnpm it frequently failed — and when it did, thepostinstallscript was never executed at all (that was tracked as #24333).Status
Both are fixed on
mainby #25779, which is why this issue got closed automatically. The behaviour now:postinstallscript that exits non-zero fails the task with anExecutionFailedExceptionthat names the package and includes the script's captured stdout/stderr, instead of the exit code being discarded.--config.verify-deps-before-run=falsewhen pnpm is the package manager (nothing extra for npm, and nothing for bun, which rejects unknown arguments).prepare-frontend/build-frontendin the Maven and Gradle plugins) fails the build, and in development the node tasks failure propagates out ofDevModeInitializer.runNodeTasks, so the dev server reports the error instead of hot-reloading a broken bundle.Regression coverage was added in
TaskRunNpmInstallTest(a fake package whosepostinstallprints to stderr and exits non-zero must makeexecute()throw with the package name and the script output), plus unit tests for the resolved postinstall arguments per package manager.Note on the behaviour change
Projects that until now had a silently failing
postinstallscript will start failing their build. That is the intended fix, but if someone needs to opt a package out,excludePostinstallPackages(Maven:vaadin.npm.excludePostinstallPackages, Gradle:excludePostinstallPackages) accepts.for the project's ownpackage.json.Backporting
The fix is labelled for
25.2and25.3. @willemv — since you reported this against 24.7.5, please say if you need it on the 24.x line as well, so a maintainer can decide on an additional cherry-pick.fix: stop pnpm from reinstalling before the postinstall script (#25779)…
fix: stop pnpm from reinstalling before the postinstall script (#25779)
willemv commentedon Sep 22, 2026
I don't need a backport to 24.x, thanks.
fix: stop pnpm from reinstalling before the postinstall script (vaadi…
vaadin-bot commentedon Sep 29, 2026
This ticket/PR has been released with Vaadin 25.4.0-alpha1.