vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
611 stars 167 forks source link

Beacon API based eager UI closing is broken on Firefox and Safari #19305

Open mstahv opened 5 months ago

mstahv commented 5 months ago

Description of the bug

It looks like the detach event is not firer "eagerly" when leaving the page (using a beacon request) when Firefox is used. With Safari I also noticed some issues with one project, but can't reproduce with a fresh project (some caching issue mayby on Safari 🤷‍♂️). With Chrome it always works.

Expected behavior

The detach event should be fired whan navigating away or closing the window within a reasonable time.

Minimal reproducible example

Override onDetach and see when it actually happens.

Versions

Flow: 24.3.9 Vaadin: 24.3.10 Java: Eclipse Adoptium 22.0.1 OS: aarch64 Mac OS X 14.4.1 Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101 Firefox/125.0

mstahv commented 5 months ago

Might be I was holding it wrong. FF at least sometimes don't properly do beacon request. https://bugzilla.mozilla.org/show_bug.cgi?id=1609653

Legioth commented 5 months ago

I wouldn't be surprised if this is just the way some browser implementations work and there's nothing we can do about it.

TatuLund commented 4 months ago

We have seen this Firefox problem also in our Vaadin 8 integration tests, as they are run both in Chrome and Firefox.

TatuLund commented 3 months ago

The workaround with Firefox is to do it in the old fashioned way: https://github.com/TatuLund/vaadin-create23/blob/master/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java#L77