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

In a hybrid application, Flow fails after doing HMR and reloading Flow.tsx #19291

Closed
Artur- opened this issue May 2, 2024 · 2 comments · Fixed by #19323
Closed

In a hybrid application, Flow fails after doing HMR and reloading Flow.tsx #19291

Artur- opened this issue May 2, 2024 · 2 comments · Fixed by #19323

Comments

@Artur-
Copy link
Member

Artur- commented May 2, 2024

Description of the bug

If you have a React main layout and show a Flow view inside that, then performing a change to the main layout in some cases causes

Uncaught (in promise) Error: Application ROOT-2521314 already initialized
    at window.Vaadin.Flow.initApplication (FlowBootstrap.js:93:17)
    at Module.init (FlowBootstrap.js:259:22)
    at Flow.flowInit (Flow.ts:320:20)
    at async Object.action (Flow.ts:194:11)
window.Vaadin.Flow.initApplication @ FlowBootstrap.js:93
init @ FlowBootstrap.js:259
flowInit @ Flow.ts:320
Promise.then (async)
(anonymous) @ Flow.tsx:279
commitHookEffectListMount @ react-dom.development.js:23150

It happens because a new instance of Flow is created when the MainLayout is hot deployed. This in turn causes the isFlowClientLoaded() check to return false (it checks state from the Flow instance) but the real initialization throws an error as the flow client really is loaded and present in the DOM.

Expected behavior

There is no error

Minimal reproducible example

Tested with the Copilot hybrid test app

Versions

  • Vaadin / Flow version:
  • Java version:
  • OS version:
  • Browser version (if applicable):
  • Application Server (if applicable):
  • IDE (if applicable):
@caalador caalador self-assigned this May 6, 2024
mshabarov pushed a commit that referenced this issue May 10, 2024
Reset and reload flow when a
template hrm reload happens.

Fixes #19291
vaadin-bot pushed a commit that referenced this issue May 10, 2024
Reset and reload flow when a
template hrm reload happens.

Fixes #19291
vaadin-bot added a commit that referenced this issue May 10, 2024
Reset and reload flow when a
template hrm reload happens.

Fixes #19291

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.beta3 and is also targeting the upcoming stable 24.4.0 version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.5.0.alpha1 and is also targeting the upcoming stable 24.5.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment