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

Changing reactEnable flag and rerunning an app breaks dev bundle #20077

Closed
bwajtr opened this issue Sep 27, 2024 · 11 comments · Fixed by #20125
Closed

Changing reactEnable flag and rerunning an app breaks dev bundle #20077

bwajtr opened this issue Sep 27, 2024 · 11 comments · Fixed by #20125

Comments

@bwajtr
Copy link
Contributor

bwajtr commented Sep 27, 2024

Description of the bug

After the call to UI.getCurrent().navigate() (either by String or Class) the application renders the requested page, however the URL (location) in the browser does not change. The documentation for this method says that it should do so.

It used to work in 24.3

I tried to turn off react router, but the behavior is the same with or without the react enabled.
Reproduced in all major browsers.
It's interesting that when I use RouterLink for navigation, it works as expected.
Also, I noticed that the issue is reproducible only if there is dev.bundle present in the project. If you fetch the project below and remove dev.bundle then the navigation works as expected.

Expected behavior

I'd expect the browser location and history to be changed after call to navigate()

Minimal reproducible example

You can reproduce it using this simple project:
https://github.com/bwajtr/vaadin-browser-router-navigation-issue

  1. Start the application
  2. Go to http://localhost:8080/overview
  3. Click on Go To Detail
  4. Note that the browser location did not change

Versions

  • Vaadin / Flow version: 24.4.12
  • Java version: 17
  • OS version: MacOs Sonoma 14.6.1
  • Browser version (if applicable): Chrome 129
  • Application Server (if applicable):
  • IDE (if applicable): Intellij Idea
@bwajtr
Copy link
Contributor Author

bwajtr commented Sep 27, 2024

I've updated the description with this information

I noticed that the issue is reproducible only if there is dev.bundle present in the project. If you fetch the project below and remove dev.bundle then the navigation works as expected.

@bwajtr
Copy link
Contributor Author

bwajtr commented Sep 27, 2024

I've updated the description with information that both UI.navigate(String) and UI.navigate(Class) variants of this method are affected - the issue is reproducible for both of them

@tepi
Copy link
Contributor

tepi commented Sep 27, 2024

Confirmed on Vaadin 24.4.12. And indeed, deleting the dev.bundle makes it work.

@caalador
Copy link
Contributor

Only difference I can find is that in the supplied bundle there seems to be vaadin-router code also in the indexhtml which doesn't appear when you remove the bundle files.
Does this happen somehow when executing/building a new application?

@tepi
Copy link
Contributor

tepi commented Sep 30, 2024

Can't reproduce this with our default dev bundles or newly built ones. I guess the one provided with the example project is somehow broken/invalid, but not sure why.

@bwajtr
Copy link
Contributor Author

bwajtr commented Sep 30, 2024

I've tested again, and this is how I managed to get the "broken bundle" - I tried three times and it worked every time. What is important to note that you should try always in fresh Chrome instance (preferably in ikognito mode), because I also managed to be in state, where in the normal chrome the issue was not reproducible, but once opened the page in incognito mode, it was reproducible there. What I did is that:

  1. I used that example project, did mvn clean got rid of node_modules and removed dev.bundle. I've also left vaadin.react.enable in application.properties set to true
  2. Started the application -> no dev.bundle built; issue not reproduced
  3. Then I changed value of vaadin.react.enable to false
  4. Started the app again -> dev.bundle built this time; issue still not reproduced
  5. At this point I wondered how I managed to reproduce it in the first place
  6. I changed the value of vaadin.react.enable back to true
  7. Started the app again -> dev.bundle re-built this time; now the issue is reproducible and the router is not working correctly

I'm building on MacOs Sonoma 14.6.1, this is a log from the app when the bundle is "broken"

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.9)

2024-09-30T14:21:28.952+02:00  INFO 86255 --- [  restartedMain] org.vaadin.example.Application           : Starting Application using Java 17.0.7 with PID 86255 (/Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24/target/classes started by wajtr in /Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24)
2024-09-30T14:21:28.954+02:00  INFO 86255 --- [  restartedMain] org.vaadin.example.Application           : No active profile set, falling back to 1 default profile: "default"
2024-09-30T14:21:28.973+02:00  INFO 86255 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2024-09-30T14:21:28.973+02:00  INFO 86255 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2024-09-30T14:21:29.407+02:00  INFO 86255 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-09-30T14:21:29.413+02:00  INFO 86255 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-09-30T14:21:29.413+02:00  INFO 86255 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.28]
2024-09-30T14:21:29.434+02:00  INFO 86255 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-09-30T14:21:29.434+02:00  INFO 86255 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 460 ms
2024-09-30T14:21:29.493+02:00  INFO 86255 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing AtmosphereFramework
2024-09-30T14:21:32.293+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.VaadinServletContextInitializer  : Search for subclasses and classes with annotations took 2755 ms
2024-09-30T14:21:32.542+02:00  INFO 86255 --- [  restartedMain] c.v.b.d.startup.DevModeStartupListener   : Starting dev-mode updaters in /Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24 folder.
2024-09-30T14:21:32.567+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.f.s.FullDependenciesScanner      : Visited 106 classes. Took 14 ms.
2024-09-30T14:21:32.568+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Checking if a development mode bundle build is needed
2024-09-30T14:21:32.582+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Dependency react-dom is missing from the bundle
2024-09-30T14:21:32.582+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Dependency react-router-dom is missing from the bundle
2024-09-30T14:21:32.582+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Dependency react is missing from the bundle
2024-09-30T14:21:32.582+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Dependency @vaadin/react-components is missing from the bundle
2024-09-30T14:21:32.582+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Dependency @vaadin/react-components-pro is missing from the bundle
2024-09-30T14:21:32.583+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : A development mode bundle build is needed
2024-09-30T14:21:32.612+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
2024-09-30T14:21:32.776+02:00  INFO 86255 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2024-09-30T14:21:33.511+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : using '/Users/wajtr/.nvm/versions/node/v20.12.2/bin/npm --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install' for frontend package installation
2024-09-30T14:21:33.655+02:00  INFO 86255 --- [  restartedMain] c.v.f.s.DefaultDeploymentConfiguration   : 
Vaadin is running in DEVELOPMENT mode - do not use for production deployments.
2024-09-30T14:21:33.662+02:00  INFO 86255 --- [  restartedMain] c.vaadin.flow.spring.SpringInstantiator  : The number of beans implementing 'I18NProvider' is 0. Cannot use Spring beans for I18N, falling back to the default behavior
2024-09-30T14:21:33.678+02:00  INFO 86255 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2024-09-30T14:21:33.683+02:00  INFO 86255 --- [  restartedMain] org.vaadin.example.Application           : Started Application in 4.883 seconds (process running for 5.144)
2024-09-30T14:21:40.025+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : Frontend dependencies resolved successfully.
2024-09-30T14:21:40.661+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskCopyFrontendFiles   : Copying frontend resources from jar files ...
2024-09-30T14:21:40.707+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskCopyFrontendFiles   : Visited 21 resources. Took 45 ms.
2024-09-30T14:21:40.786+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskRunDevBundleBuild   : Creating a new development mode bundle. This can take a while but will only run when the project setup is changed, addons are added or frontend files are modified
2024-09-30T14:21:50.205+02:00  INFO 86255 --- [onPool-worker-1] c.v.f.s.frontend.TaskRunDevBundleBuild   : Development frontend bundle built
2024-09-30T14:22:09.164+02:00  INFO 86255 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-09-30T14:22:09.164+02:00  INFO 86255 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-09-30T14:22:09.165+02:00  INFO 86255 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

@tepi
Copy link
Contributor

tepi commented Sep 30, 2024

Thank you! Possibly related: #19951 and vaadin/docs@3689d9d.

In short: if toggling reactEnable on/off, it should be set both as a config parameter and vaadin/flow plugin parameter and the values need to match.

@tepi
Copy link
Contributor

tepi commented Oct 1, 2024

Tested the procedure described in #20077 (comment), while also adding reactEnable parameter for the vaadin maven plugin - and keeping its value in sync with the one in application.properties. Could not reproduce the issue with that configuration.

@bwajtr Could you test and confirm that it works for you too with the new instructions?

@bwajtr
Copy link
Contributor Author

bwajtr commented Oct 1, 2024

I've tried the steps with new instructions -> also changing the maven configuration parameter reactEnable ... but I can still reproduce the issue. Maybe because I'm running the application using IntelliJ Idea run configuration, instead of mvn spring-boot:run.

However, I've tried to use mvn spring-boot:run in the test scenario and with that it is even worse:

  1. I'm always changing both the application property and maven config at the same time
  2. I'm using mvn spring-boot:run exclusively to run the app
  3. I can reproduce the issue right in the step 4. -> when react router is set to false

This is the log of the run with mvn spring-boot:run where the bundle is "broken":

  skeleton-starter-flow-spring-24 git:(main) ✗ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.example:spring-skeleton >---------------------
[INFO] Building Project base for Spring Boot and Vaadin Flow 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot:3.2.9:run (default-cli) > test-compile @ spring-skeleton >>>
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ spring-skeleton ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] 
[INFO] >>> vaadin:24.4.12:prepare-frontend (default) > :configure @ spring-skeleton >>>
[INFO] 
[INFO] --- vaadin:24.4.12:configure (configure) @ spring-skeleton ---
[INFO] Reflections took 529 ms to scan 189 urls, producing 7167 keys and 39283 values
[INFO] 
[INFO] <<< vaadin:24.4.12:prepare-frontend (default) < :configure @ spring-skeleton <<<
[INFO] 
[INFO] 
[INFO] --- vaadin:24.4.12:prepare-frontend (default) @ spring-skeleton ---
[INFO] Reflections took 201 ms to scan 189 urls, producing 7167 keys and 39283 values
[INFO] Reflections took 174 ms to scan 189 urls, producing 7167 keys and 39283 values
[INFO] Reflections took 180 ms to scan 189 urls, producing 7167 keys and 39283 values
[INFO] Visited 108 classes. Took 68 ms.
[INFO] Copying frontend resources from jar files ...
[INFO] Visited 188 resources. Took 79 ms.
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ spring-skeleton ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ spring-skeleton ---
[INFO] Copying 1 resource from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ spring-skeleton ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot:3.2.9:run (default-cli) < test-compile @ spring-skeleton <<<
[INFO] 
[INFO] 
[INFO] --- spring-boot:3.2.9:run (default-cli) @ spring-skeleton ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.9)

2024-10-01T12:24:26.498+02:00  INFO 99093 --- [  restartedMain] org.vaadin.example.Application           : Starting Application using Java 17.0.7 with PID 99093 (/Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24/target/classes started by wajtr in /Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24)
2024-10-01T12:24:26.499+02:00  INFO 99093 --- [  restartedMain] org.vaadin.example.Application           : No active profile set, falling back to 1 default profile: "default"
2024-10-01T12:24:26.517+02:00  INFO 99093 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2024-10-01T12:24:26.517+02:00  INFO 99093 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2024-10-01T12:24:26.930+02:00  INFO 99093 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-10-01T12:24:26.935+02:00  INFO 99093 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-10-01T12:24:26.935+02:00  INFO 99093 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.28]
2024-10-01T12:24:26.961+02:00  INFO 99093 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-10-01T12:24:26.961+02:00  INFO 99093 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 444 ms
2024-10-01T12:24:27.021+02:00  INFO 99093 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing AtmosphereFramework
2024-10-01T12:24:29.749+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.VaadinServletContextInitializer  : Search for subclasses and classes with annotations took 2677 ms
2024-10-01T12:24:29.976+02:00  INFO 99093 --- [  restartedMain] c.v.b.d.startup.DevModeStartupListener   : Starting dev-mode updaters in /Users/wajtr/Developer/temp/skeleton-starter-flow-spring-24 folder.
2024-10-01T12:24:29.999+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.f.s.FullDependenciesScanner      : Visited 106 classes. Took 13 ms.
2024-10-01T12:24:30.000+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Checking if a development mode bundle build is needed
2024-10-01T12:24:30.000+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : Bundle build required for non default router.
2024-10-01T12:24:30.000+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.frontend.BundleValidationUtil    : A development mode bundle build is needed
2024-10-01T12:24:30.043+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : Running `npm install` to resolve and optionally download frontend dependencies. This may take a moment, please stand by...
2024-10-01T12:24:30.199+02:00  INFO 99093 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2024-10-01T12:24:30.927+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : using '/Users/wajtr/.nvm/versions/node/v20.12.2/bin/npm --no-update-notifier --no-audit --scripts-prepend-node-path=true --ignore-scripts install' for frontend package installation
2024-10-01T12:24:31.054+02:00  INFO 99093 --- [  restartedMain] c.v.f.s.DefaultDeploymentConfiguration   : 
Vaadin is running in DEVELOPMENT mode - do not use for production deployments.
2024-10-01T12:24:31.062+02:00  INFO 99093 --- [  restartedMain] c.vaadin.flow.spring.SpringInstantiator  : The number of beans implementing 'I18NProvider' is 0. Cannot use Spring beans for I18N, falling back to the default behavior
2024-10-01T12:24:31.078+02:00  INFO 99093 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2024-10-01T12:24:31.082+02:00  INFO 99093 --- [  restartedMain] org.vaadin.example.Application           : Started Application in 4.717 seconds (process running for 4.909)
2024-10-01T12:24:33.306+02:00  INFO 99093 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-10-01T12:24:33.306+02:00  INFO 99093 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-10-01T12:24:33.307+02:00  INFO 99093 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2024-10-01T12:24:35.433+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskUpdatePackages      : Frontend dependencies resolved successfully.
2024-10-01T12:24:36.029+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskCopyFrontendFiles   : Copying frontend resources from jar files ...
2024-10-01T12:24:36.074+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskCopyFrontendFiles   : Visited 21 resources. Took 44 ms.
2024-10-01T12:24:36.149+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskRunDevBundleBuild   : Creating a new development mode bundle. This can take a while but will only run when the project setup is changed, addons are added or frontend files are modified
2024-10-01T12:24:43.244+02:00  INFO 99093 --- [onPool-worker-1] c.v.f.s.frontend.TaskRunDevBundleBuild   : Development frontend bundle built

@tepi
Copy link
Contributor

tepi commented Oct 1, 2024

@bwajtr Thanks! Need to retry this a couple times more then. I was using mvn spring-boot:run the whole time and on previous attempts I could not reproduce the issue. I'll comment when I've tested it a bit more.

@tepi
Copy link
Contributor

tepi commented Oct 1, 2024

Alright, can reproduce the issue now. While investigating what we need to change to make it work, looks like at least for me, after changin both properties, running mvn clean vaadin:clean-frontend spring-boot:run seems to provide a workaround.

@tepi tepi changed the title UI.navigate() navigates to new route but does not change URL (location) in the browser Changing reactEnable flag and rerunning an app breaks dev bundle Oct 1, 2024
@tepi tepi self-assigned this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants