Potential beacon problems with Chrome

NOTE: I also posted this here, as it may be a bug.

We see the following client-side error 100+ times a day:

TypeError: Illegal invocation
 at eval at Q3 (https://myurl.com/VAADIN/build/FlowClient-urjGN_YE.js:3:42383), <anonymous>(sendBeacon:8:13)
 at eval at Q3 (https://myurl.com/VAADIN/build/FlowClient-urjGN_YE.js:3:42383), <anonymous>(HTMLBodyElement.eval:13:1)
 at eval at Q3 (https://myurl.com/VAADIN/build/FlowClient-urjGN_YE.js:3:42383), <anonymous>(Object.eval:13:17)
 at /VAADIN/build/FlowClient-urjGN_YE.js(Q3:3:42444)
 at /VAADIN/build/FlowClient-urjGN_YE.js(Bg:3:22831)
 at /VAADIN/build/FlowClient-urjGN_YE.js(Xm:1:24808)
 at /VAADIN/build/FlowClient-urjGN_YE.js(om:1:19919)
 at /VAADIN/build/FlowClient-urjGN_YE.js(z.cb:3:69323)
 at /VAADIN/build/FlowClient-urjGN_YE.js(Jr:3:15280)
 at /VAADIN/build/FlowClient-urjGN_YE.js(nE:3:45560)
 at /VAADIN/build/FlowClient-urjGN_YE.js(z.C:3:69109)
 at /VAADIN/build/FlowClient-urjGN_YE.js(_r:1:41536)
 at /VAADIN/build/FlowClient-urjGN_YE.js(z.bb:3:58847)
 at /VAADIN/build/FlowClient-urjGN_YE.js(z.I:3:63223)
 at /VAADIN/build/FlowClient-urjGN_YE.js(null:3:12404)

It seems to only occur for Chrome on Windows, including the latest version.

If I remember right, Vaadin uses beacons to signal when a page is closed and destroys the UI instance. I also remember reading somewhere that Chrome is finicky with the events you can use to detect a page close. Perhaps Chrome does not allow JS code executed after a tab/window is close, so pagehide will not work?

We do not have any extra code that deals with beacons that could cause this.

The error most likely is thrown after the page is closed, so I have no idea how to reproduce it on local, since the console goes away. The only reason we noticed this is because of LogRocket, a session replay tool.

  • Vaadin Platform version: 24.3.8
  • Java version: 21

Hi Oliver.

I’ve found this that might be related. It could be that it is indeed a bug because under some circumstances the sendBeacon method is being invoked with a wrong context.

The problem indeed seems to be that it is probably difficult to reproduce.