Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
skiedrowski opened this issue Apr 29, 2022 · 9 comments · Fixed by #16520
Closed

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

skiedrowski opened this issue Apr 29, 2022 · 9 comments · Fixed by #16520

Comments

@skiedrowski
Copy link

skiedrowski commented Apr 29, 2022

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 [email protected]: 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

  • Vaadin / Flow version: reproduced with 23.0.5 and 23.0.7
  • Java version: 11.0.14, 11.0.11
  • OS version: macOS 12.3.1, macOS 10.15.5
  • Hardware: MacBook Pro M1 Max, MacBook Pro Intel i9
  • Browser version: Safari 15.4 and Chrome 101.0.4951.41
  • Application Server: reproduced with Payara Server (Full) 5.2022.2 and Payara Server (Full) 5.2020.6
  • IDE (if applicable): not relevant (IntelliJ IDEA 2022.1 Ultimate)
@Artur-
Copy link
Member

Artur- commented Apr 29, 2022

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

@skiedrowski
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

only with productionMode = false

@Artur-
Copy link
Member

Artur- commented Apr 29, 2022

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
Copy link
Collaborator

mcollovati commented Apr 29, 2022

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
Copy link
Collaborator

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

@ebanchio
Copy link

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

czp13 pushed a commit that referenced this issue Apr 21, 2023
…ernal processes (#16520)

When running an external process using INHERIT redirect strategy may break in some situations as the output is written directly to the main process stream. Errors may also arise on some OS when the strategy is PIPE (the default) and the streams are not completely consumed, as the call for Process.waitFor may hang indefinitely.

This change uses PIPE for external processes and consumes both input and error streams of the started process, introducing a method to read the stream asynchronously and using it to ensure streams are consumed when running frontend tools commands. Covering tests were added. 

Fixes:
- #13655 and #15339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants