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

Javascript error: Invalid blocker state transition #20404

Open
jcgueriaud1 opened this issue Nov 4, 2024 · 6 comments · May be fixed by #20446
Open

Javascript error: Invalid blocker state transition #20404

jcgueriaud1 opened this issue Nov 4, 2024 · 6 comments · May be fixed by #20446

Comments

@jcgueriaud1
Copy link
Contributor

jcgueriaud1 commented Nov 4, 2024

Description of the bug

When I'm navigating in my Vaadin application I have some javascript errors.

Uncaught (in promise) Error: Invalid blocker state transition: unblocked -> proceeding

image

image

Expected behavior

A javascript error should not appear in a normal case of usage.

Minimal reproducible example

Create a Vaadin application with two views in a menu, clicks multiple times on the menu.

I think the error appears when you click on the menu when the application is already navigating so if the view is really fast to load you need to click fast.

Versions

  • Vaadin / Flow version: 24.5.2
@jcgueriaud1
Copy link
Contributor Author

This might be connected: https://github.com/vaadin/copilot-internal/issues/3247

@mshabarov
Copy link
Contributor

This looks like a misconfiguration or misusing of React's blocker function in Flow.tsx (ReactRouter/Flow integration).

@Lodin
Copy link
Contributor

Lodin commented Nov 6, 2024

To me, this error looks like connected to the useBlocker hook. My first guess is that it somehow called multiple time that interrupts state change inside the blocker. So, it probably requires some debouncing 🤔

@mshabarov
Copy link
Contributor

To me, this error looks like connected to the useBlocker hook

Exactly, this was what I meant.

@mcollovati
Copy link
Collaborator

Maybe a check is missing here in the serverConnected callback defintion

containerRef.current.serverConnected = (cancel) => {
if (cancel) {
blocker.reset();
blockingPromise.resolve();
} else {
blocker.proceed();
blockingPromise.resolve();
}
}

@caalador caalador self-assigned this Nov 7, 2024
@caalador
Copy link
Contributor

caalador commented Nov 8, 2024

I guess the main issue here is that the sample layout uses <SideNav onNavigate={({ path }) => navigate(path!)} location={location}> which directly calls react navigate so it doesn't go to the queued navigation Flow uses. Doing a server side navigate I can not get the exception to happen, but can easily be gotten on a slow 4g network with the client sideNav.

caalador added a commit that referenced this issue Nov 12, 2024
Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404
@caalador caalador linked a pull request Nov 12, 2024 that will close this issue
@caalador caalador moved this to 🔎Iteration reviews in Vaadin Flow ongoing work (Vaadin 10+) Nov 13, 2024
@caalador caalador moved this from 🔎Iteration reviews to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Status: 🔎Iteration reviews
Development

Successfully merging a pull request may close this issue.

5 participants