vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
927 stars 56 forks source link

Infinite project reloading #2573

Open victj99 opened 5 months ago

victj99 commented 5 months ago

Describe the bug

When I create a project with npm vaadin init and run it, it keeps reloading without stopping.

https://github.com/vaadin/hilla/assets/44973221/26187df5-128e-44ad-8214-74087644589f

Expected-behavior

No response

Reproduction

Create a new project with npm vaadin init.

Run the project

System Info

Macos Sonoma 14.5 Java 21

marcushellberg commented 5 months ago

Seems like it might be the same as https://github.com/vaadin/flow/issues/19280

trapperkeeper commented 4 months ago

I am experiencing the same issue. If I download the Hello World project FLOW/Java, it starts fine. But if I use the app starter UI (https://start.vaadin.com/app/p) and create a React (Hilla) app, I get an infinite restart loop.

I see this in the output: "Restarting due to 2 class path changes (0 additions, 0 deletions, 2 modifications)"

I feel like the React build is creating files that the Spring devtools is seeing as new. Perhaps there is a way to exclude those files? I tried to identify and ignore a couple of files that I thought might be the culprits, but no luck so far.

trapperkeeper commented 4 months ago

I should note that adding the following to application.properties prevents the infinite restarts. However, it at least partly disabled hot reloading as well:

spring.devtools.restart.enabled = false

codercodingthecode commented 4 months ago

I found a way to stop the application from rebooting. Until a permanent solution comes from the Vaadin team or the IDE maintainers, it seems like the hot-reload scripts are targeting files in src/main/frontend/generated/. This causes the application to keep rebooting/reloading infinitely.

For me, the solution was to add an exclude watch for that directory. Updates to the backend and frontend hot reload now work as expected.

Apply this in your VSCode/Cursor settings, add the following to your settings.json:


{
  "files.watcherExclude": {
    "**/src/main/frontend/generated/**": true
  },
}
trapperkeeper commented 4 months ago

Thank you Andy. I was also able to get around this issue, but my solution may not be as workable for everyone as yours. I disabled the Java Debugger VSCode extension from Microsoft. That stopped the continuous reloading behavior. When I re-enabled the plugin, it did not return. The problem is, I have no explanation for why that would have worked.

On Thu, 18 Jul 2024 at 19:43, Andy @.***> wrote:

I found a way to stop the application from rebooting. Until a permanent solution comes from the Vaadin team or the IDE maintainers, it seems like the hot-reload scripts are targeting files in src/main/frontend/generated/. This causes the application to keep rebooting/reloading infinitely.

For me, the solution was to add an exclude watch for that directory. Updates to the backend and frontend hot reload now work as expected.

Apply this in your VSCode/Cursor settings, add the following to your settings.json:

{ "files.watcherExclude": { "/src/main/frontend/generated/": true }, }

— Reply to this email directly, view it on GitHub https://github.com/vaadin/hilla/issues/2573#issuecomment-2237971112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPUEWWLTZFY4AFPEE2OKNTZNB4NRAVCNFSM6AAAAABJ2DZB7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXHE3TCMJRGI . You are receiving this because you commented.Message ID: @.***>

Tostino commented 5 days ago

Having the same issue with a Hilla based project I created from the starter just recently.

Using IntelliJ IDEA.

If I disable vaadin.frontend.hotdeploy then the app stops constantly restarting, but my components also don't look like they have the correct styling when I do that.

taefi commented 5 days ago

I cannot reproduce an infinite number of reloads/restarts on my machine: macOS 15.0.1, Vaadin 24.5.5, Java 21, Node v20.11.1, Vite v5.4.11

I tried the following combinations:

All of the above are clean starts (first start in after downloading/generating a project).

First of all, I removed the "On frame deactivation" option from the IDEA run configurations (which was set to "Update classes and resources"). Anyway, after a couple of restarts (triggered by spring-devtools) it finally settles down and the application runs without any obvious problems.

By adding the following hint

logging.level.org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration=DEBUG

for the logger in application.properties, it reveals the followings (sometimes only one of the followings, sometimes, both):

Restarting due to 4 class path changes (1 addition, 0 deletions, 3 modifications)
Change set: [/path/to/project/target/classes [/path/to/project/target/classes/com/example/application/Application.class (MODIFY), 
/path/to/project/target/classes/com/example/application/services/HelloWorldService.class (MODIFY),
/path/to/project/target/classes/com/example/application/services/package-info.class (MODIFY),
/path/to/project/target/classes/application.properties (ADD)]]
...
Restarting due to 7 class path changes (0 additions, 0 deletions, 7 modifications)
Change set: [/path/to/project/target/classes [/path/to/project/target/classes/META-INF/resources/images/empty-plant.png (MODIFY),
/path/to/project/target/classes/META-INF/resources/icons/icon.png (MODIFY),
/path/to/project/target/classes/banner.txt (MODIFY),
/path/to/project/target/classes/com/example/application/Application.class (MODIFY),
/path/to/project/target/classes/com/example/application/services/HelloWorldService.class (MODIFY),
/path/to/project/target/classes/com/example/application/services/package-info.class (MODIFY),
/path/to/project/target/classes/application.properties (MODIFY)]]

Could someone (@trapperkeeper , @Tostino , @codercodingthecode) please kindly share an application that reproduce the infinite number of reloads/restarts issue in a deterministic way?

trapperkeeper commented 4 days ago

@taefi , when I experienced this issue, the project came directly from the app starter UI (https://start.vaadin.com/app/p) when creating a React (Hilla) app. I tried it several times and always got an infinite restart loop. That said, as you will note within this thread, the issue ended up some how related to the interplay between the vaadin app and the the Java Debugger VSCode extension from Microsoft. When I disabled that extension, the problem went away. When I re-enabled it, the issue did not return.