`onDetach` not called when reloading the page


We have multiple parent layouts:

public class Root extends PolymerTemplate<TemplateModel> implements RouterLayout
public class Parent extends PolymerTemplate<TemplateModel> implements RouterLayout
@Route(layout = Parent.class, value = Child.ROUTE)
public class Child extends PolymerTemplate<TemplateModel>

In our Parent and our Child we are implementing the onAttach and the onDetach to subscribe / unsubscribe to / from an event bus. The onDetach is never called when we reload the page. onAttach is always called when we reload the page. That means we subscribe multiple times but we never unsubscribe.

Is that a wanted behaviour?

Sounds like what https://github.com/vaadin/flow/pull/4183 fixed?

Except that the old UI is not immediately detached when you refresh… I think it’s only detached right now when the session expires

If we reload the page we create a new instance so we have two different instance now. The old one and the new. But both instances are getting the events since we never where able to unsubscribe from the eventbus because we have nothing in the lifecycle which would detect the page reload. That would also mean that our old instance session never expires since it always gets a heartbeat when there are new events.

The old UI should be closed and detached when it has missed 3 heartbeats. The heartbeats come from the browser, so sending an event to the UI on the server has no effect on that.

Thank you for clarification!