Vaadin flow threads syncronization and lifycycle

Okan BEKATLI:
Just want to check if this is still valid with 14.4.0.

I have a simple button with addClickListener and addClickShortcut. It works without any issue if clicked on button with mouse.

But when I use ENTER key as a shortcut it generates:

2020-10-19 13:20:00.231 WARN 7228 — [io-8080-exec-25]
c.v.f.s.c.r.AbstractRpcInvocationHandler : Got an RPC for non-existent node: 51

ignorable or not ?

		proceedButton.addClickShortcut(Key.ENTER);
		proceedButton.addClickListener(e->
		{
			LOGGER.info("button clicked");
			UI.getCurrent().navigate(PublicPage.class);
		});

This error message seems to be caused by this bug: https://github.com/vaadin/flow/issues/8037

Apparently, the click listener is triggered twice when the Button is focused. In your case, it is the second triggering that causes the error since the server is receiving an RPC from a Button that should have been discarded already (since you navigate away).

Meanwhile, a hacky workaround to make the error go away is to have a counter that gets incremented per click event. Then you can use that to do the navigation only when the second click event is received:

int counter = 0;
proceedButton.addClickShortcut(Key.ENTER);
		proceedButton.addClickListener(e->
		{
            counter++;
			LOGGER.info("button clicked");
            if ((counter % 2) == 0) {
			  UI.getCurrent().navigate(PublicPage.class);
            }
		});