vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
622 stars 166 forks source link

Vaadin 23 Dev Mode + Payara -> NPM Dependency Error #13655

Closed skiedrowski closed 1 year ago

skiedrowski commented 2 years ago

Description of the bug

Deploying a simple Vaadin application in dev mode to Payara Server 5.2022.2 causes NPM Dependency ERROR. Deploying the same application to Tomcat works fine. Deploying the same application in production mode works with both servers.

Expected behavior

Dev Mode should be available with Vaadin 23 and Payara.

Minimal reproducible example

Preparation

  1. generate default app start.vaadin.com
  2. publish to github (https://github.com/skiedrowski/vaadinDevModeTrouble)
  3. modify for war deployment (https://vaadin.com/blog/packaging-and-deploying-spring-boot-applications-as-war-files)
  4. push to github

Tomcat works

  1. clone repo https://github.com/skiedrowski/vaadinDevModeTrouble into vaadinDevModeTroubleTomcat
  2. run ./mvnw package
  3. Download and extract Tomcat 9.0.62 into project
  4. start Tomcat (cd apache-tomcat-9.0.62/bin/ && ./startup.sh)
  5. Deploy to Tomcat (cd ../.. && cp target/myapp.war apache-tomcat-9.0.62/webapps/)
  6. open http://localhost:8080/myapp/ --> works fine
  7. shutdown apache-tomcat-9.0.62/bin/shutdown.sh

Payara fails

  1. clone repo https://github.com/skiedrowski/vaadinDevModeTrouble into vaadinDevModeTroublePayara
  2. run ./mvnw package
  3. Download and extract Payara 5.2022.2 into project
  4. start Payara (payara5/bin/asadmin start-domain)
  5. Deploy to Payara (payara5/bin/asadmin deploy target/myapp.war)
  6. open http://localhost:8080/myapp/

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Apr 29 08:01:53 CEST 2022 There was an unexpected error (type=Internal Server Error, status=500).

payara5/glassfish/domains/domain1/logs/server.log contains

[2022-04-29T08:49:45.257+0200] [Payara 5.2022.2] [INFORMATION] [] [] [tid: _ThreadID=101 _ThreadName=ForkJoinPool.commonPool-worker-19] [timeMillis: 1651214985257] [levelValue: 800] [[
  2022-04-29 08:49:45.257 ERROR 48064 --- [nPool-worker-19] c.v.f.s.frontend.TaskUpdatePackages      : Command `/Users/sascha/.vaadin/node/node /Users/sascha/.vaadin/node/node_modules/npm/bin/npm-cli.js --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install` failed:

]]

[2022-04-29T08:49:45.257+0200] [Payara 5.2022.2] [INFORMATION] [] [] [tid: _ThreadID=101 _ThreadName=ForkJoinPool.commonPool-worker-19] [timeMillis: 1651214985257] [levelValue: 800] [[
  2022-04-29 08:49:45.257 ERROR 48064 --- [nPool-worker-19] c.v.f.s.frontend.TaskUpdatePackages      : >>> Dependency ERROR. Check that all required dependencies are deployed in npm repositories.
]]

[2022-04-29T08:49:55.254+0200] [Payara 5.2022.2] [INFORMATION] [] [] [tid: _ThreadID=112 _ThreadName=http-thread-pool::http-listener-1(5)] [timeMillis: 1651214995254] [levelValue: 800] [[
  2022-04-29 08:49:55.254 ERROR 48064 --- [p-listener-1(5)] c.v.flow.server.DefaultErrorHandler      : 

java.lang.IllegalStateException: com.vaadin.flow.server.ExecutionFailedException: Npm install has exited with non zero status. Some dependencies are not installed. Check npm command output
    at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:769) ~[vaadin-dev-server-23.0.5.jar:na]
    at com.vaadin.base.devserver.AbstractDevServerRunner.getCause(AbstractDevServerRunner.java:765) ~[vaadin-dev-server-23.0.5.jar:na]
    at com.vaadin.base.devserver.AbstractDevServerRunner.handleRequest(AbstractDevServerRunner.java:631) ~[vaadin-dev-server-23.0.5.jar:na]
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1567) ~[flow-server-23.0.5.jar:23.0.5]
    at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:299) ~[flow-server-23.0.5.jar:23.0.5]
...
Caused by: com.vaadin.flow.server.ExecutionFailedException: Npm install has exited with non zero status. Some dependencies are not installed. Check npm command output
...

~/.npm/_logs/2022-04-29T06_49_42_618Z-debug-0.log contains

272 warn deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
273 timing reifyNode:node_modules/source-map-url Completed in 1755ms
274 verbose stack Error: write EPIPE
274 verbose stack     at afterWriteDispatched (node:internal/stream_base_commons:160:15)
274 verbose stack     at writeGeneric (node:internal/stream_base_commons:151:3)
274 verbose stack     at Socket._writeGeneric (node:net:795:11)
274 verbose stack     at Socket._write (node:net:807:8)
274 verbose stack     at writeOrBuffer (node:internal/streams/writable:389:12)
274 verbose stack     at _write (node:internal/streams/writable:330:10)
274 verbose stack     at Socket.Writable.write (node:internal/streams/writable:334:10)
274 verbose stack     at EventEmitter.log.write (/Users/sascha/.vaadin/node/node_modules/npm/node_modules/npmlog/lib/log.js:362:10)
274 verbose stack     at EventEmitter.<anonymous> (/Users/sascha/.vaadin/node/node_modules/npm/node_modules/npmlog/lib/log.js:297:12)
274 verbose stack     at Array.forEach (<anonymous>)
275 verbose cwd /Users/sascha/zitecs/src/com.zitecs/ologis/core/vaadinDevModeTroublePayara
276 verbose Darwin 21.4.0
277 verbose argv "/Users/sascha/.vaadin/node/node" "/Users/sascha/.vaadin/node/node_modules/npm/bin/npm-cli.js" "--no-update-notifier" "--no-audit" "--scripts-prepend-node-path=true" "--ignore-scripts" "install"
278 verbose node v16.14.2
279 verbose npm  v8.5.0
280 error code EPIPE
281 error syscall write
282 error errno -32
283 error write EPIPE
284 verbose exit -32
  1. shutdown payara5/bin/asadmin stop-domain

Versions

Artur- commented 2 years ago

Does it reproduce consistently because it looks like a temporary network error or something similar?

skiedrowski commented 2 years ago

Yes, always. Tested on two different MacBooks in two different networks. Switching to production mode solves the issue on both MacBooks in both networks.

mcollovati commented 2 years ago

Not strictly related, but I'm struggling with the exactly same problem when running V23 on vertx-maven-plugin. It happens locally and also on CI (circleci and github actions). Tried also with different node and npm version, but still have the same error. To be noted that running npm command manually works as expected.

skiedrowski commented 2 years ago

Not strictly related, but I'm struggling with the exactly same problem when running V23 on vertx-maven-plugin. ...

only with productionMode = false or also with productionMode = true? (since my issue only happens when productionMode = false)

mcollovati commented 2 years ago

only with productionMode = false

Artur- commented 2 years ago

With production mode you will not run ”npm install” from Java (it will run from Maven/Gradle) so you won’t see the same issue

mcollovati commented 2 years ago

It seems like the problem is related to how STDERR is handled by processes launched by the JVM. If in TaskRunNpmInstall.runNpmCommand() I change builder.redirectError(ProcessBuilder.Redirect.INHERIT) to builder.redirectError(ProcessBuilder.Redirect.PIPE), npm execution completes successfully. For vertx-maven-plugin, I think the problem is how the parent process, created by the maven plugin, handles STDERR redirection.

mcollovati commented 2 years ago

Additional fact is that error seems to happen only with WebpackHandler; with Vite enabled, all works fine in Payara.

ebanchio commented 1 year ago

Hello! Any news on this? Keep getting the same error with Vaadin 23.3.6 and Payara 5.192 (productionMode = false).