Vaadin Flow 24.1 Beacon API UI detach listener not being called on browser close

Hello,

We have a VaadinService.addUIInitListener(), and a ui.addDetachListener() and the detach listener is not being called on close. Are we missing something?

Many thanks.

public class ConfigureUIServiceInitListener implements VaadinServiceInitListener {
  @Override  
  public void serviceInit(ServiceInitEvent event) {
      VaadinService vsrv = event.getSource();
      vsrv.addUIInitListener(uiEvent -> {
        final UI ui = uiEvent.getUI();
        ui.addBeforeEnterListener(this::beforeEnter);
        ui.addBeforeLeaveListener(this::beforeLeave);
        ui.addDetachListener(this::detaching); // Why isn't this being called on browser tab close?
      });
      vsrv.addSessionInitListener(sie -> {
        String wsid = getSessionID(sie.getSession());
      });
      vsrv.addSessionDestroyListener(sde -> {
      VaadinSession vdnSess = sde.getSession();
      String id = getSessionID(vdnSess);
      // do something...
    });
  }
}

Note:

  • Vaadin 24.1 is unsupported
  • It’s important to know which browser creates the problem

Apologies, I meant to refer to a feature that was introduced in Vaadin Flow 24.1. According to the post below, as of version 24.1 Vaadin Flow now uses the Beacon API to notify about closed UIs.

We are using Vaadin 24.6.1 and Google Chrome.

I only know about a problem in Firefox (Beacon API based eager UI closing is broken on Firefox · Issue #19305 · vaadin/flow · GitHub) if you think you can reproduce it in other Browsers as well, it might be worth to create an issue on GitHub with an example

1 Like