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

Hotswap causes error when running for the first time a Gradle application that uses React #20831

Open
cromoteca opened this issue Jan 10, 2025 · 2 comments

Comments

@cromoteca
Copy link
Contributor

Description of the bug

I downloaded a Hilla/React+Gradle application from start.vaadin.com and I run it using IDEA and our plugin. Making changes to the Hilla endpoint causes the hotswap to fail. Restarting the application fixes the issue.

Expected behavior

Hotswap should work even at first launch.

Minimal reproducible example

  • download a project using Hilla/React like in the screenshot
  • open it directly in IDEA
  • change the Git add/remove settings as required by Vaadin plugin
  • launch using Debug using HotSwap Agent
  • verify that the application works and the endpoint is reached correctly
  • make a change in HelloReactEndpoint.java, for example modify the returned string
  • switch back to the browser

The server will output this:

2025-01-10T11:42:57.130+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : 11:42:57 [vite] Pre-transform error: Failed to load url /generated/vite-devmode.ts (resolved id: /generated/vite-devmode.ts). Does the file exist?
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : 11:42:57 [vite] Pre-transform error: Failed to resolve import "./vaadin-react.js" from "src/main/frontend/generated/vaadin.ts". Does the file exist?
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   Plugin: vite:import-analysis
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   File: /home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/src/main/frontend/generated/vaadin.ts:56:7
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   42 |  import "./vaadin-featureflags.js";
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   43 |  import "../index";
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   44 |  import "./vaadin-react.js";
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :      |          ^
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   45 |  import "Frontend/generated/jar-resources/vaadin-dev-tools/vaadin-dev-tools.js";
2025-01-10T11:42:57.134+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   46 |  import "./theme-hilla-react-app.global.generated.js";
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   : 11:42:57 [vite] Internal server error: Failed to resolve import "./vaadin-react.js" from "src/main/frontend/generated/vaadin.ts". Does the file exist?
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   Plugin: vite:import-analysis
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   File: /home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/src/main/frontend/generated/vaadin.ts:56:7
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   42 |  import "./vaadin-featureflags.js";
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   43 |  import "../index";
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   44 |  import "./vaadin-react.js";
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :      |          ^
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   45 |  import "Frontend/generated/jar-resources/vaadin-dev-tools/vaadin-dev-tools.js";
2025-01-10T11:42:57.159+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :   46 |  import "./theme-hilla-react-app.global.generated.js";
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at TransformPluginContext._formatError (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:47377:41)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at TransformPluginContext.error (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:47372:16)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at normalizeUrl (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:45638:23)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:45757:39
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async Promise.all (index 25)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async TransformPluginContext.transform (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:45684:7)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async EnvironmentPluginContainer.transform (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:47219:18)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async loadAndTransform (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:41030:27)
2025-01-10T11:42:57.160+01:00  INFO 95820 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker   :       at async viteTransformMiddleware (file:///home/luciano/Downloads/skeleton-starter-hilla-react-gradle-24(1)/skeleton-starter-hilla-react-gradle-24/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:42474:24)

And, as the application tries to reload, that log will repeat indefinitely.

Again, restarting the application fixes the issue.

It seems that vaadin-dev-server-settings.json is created with wrong values.

Versions

  • Vaadin / Flow version: 24.6.1
  • Java version: 21
  • OS version: Linux
  • Browser version (if applicable): Firefox 134
  • Application Server (if applicable):
  • IDE (if applicable): IDEA
IntelliJ IDEA 2024.3.1.1 (Ultimate Edition)
Build #IU-243.22562.218, built on December 18, 2024
Runtime version: 21.0.5+8-b631.28 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.X11.XToolkit
Linux 6.12.7-200.fc41.x86_64
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 8192M
Cores: 20
Registry:
  ide.experimental.ui=true
  i18n.locale=
Non-Bundled Plugins:
  org.strangeway.vaadin (243.21565.129)
  com.intellij.aqua (243.22562.230)
  com.vaadin.intellij-plugin (1.4.4)
Kotlin: 243.22562.218-IJ
Current Desktop: GNOME
@cromoteca
Copy link
Contributor Author

A similar Maven-based downloaded project works.

Also, I created a project from start.spring.io and saw the same behavior, except that it stays wrong even after restarting.

@cromoteca
Copy link
Contributor Author

This is what I see in vaadin-dev-server-settings.json:

"staticOutput": .../build/resources/main/META-INF/VAADIN/webapp/VAADIN/static",
"statsOutput": ".../build/resources/main/META-INF/VAADIN/config",
"frontendBundleOutput": ".../build/resources/main/META-INF/VAADIN/webapp",

resources/main becomes classes when the application works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Status: 🪵Product backlog
Development

No branches or pull requests

2 participants