PendingJavaScriptInvocationUtil : 1000 JavaScript invocations... in logs

This log keeps appearing from now and then:

PendingJavaScriptInvocationUtil : 1000 JavaScript invocations scheduled for this UI have not been sent to the browser yet. The most recent one was scheduled for node id=2973, element with tag 'vaadin-multi-select-combo-box', component 'com.vaadin.flow.component.combobox.MultiSelectComboBox', com.vaadin.flow.component.combobox.MultiSelectComboBox@159fbe65 with the expression 'return $0.$connector.clear($1,$2)'. The UI has an open push connection, so the invocations are most likely scheduled faster than the browser can consume them. Undelivered invocations are kept in memory until they are sent, so a growing number of them eventually causes an OutOfMemoryError. If only the latest value is relevant for the client, for example a progress value or the current time, do not schedule a new invocation for every update: either keep the PendingJavaScriptResult returned by executeJs and call cancelExecution() on it before scheduling the next one, or set an element property instead (element.setProperty(...)), since only the last value of a property is sent. A background task can also compare UI.getLastUpdateSentTimestamp() against the current time to stop scheduling updates while the client is not receiving them. This is logged once per UI. Enable debug logging for com.vaadin.flow.component.internal.PendingJavaScriptInvocationUtil to also log the call site of the invocation, or turn that logger off to silence the warning.

Does anyone know what may cause this?
Using 25.3.5 and spring-boot 4.1.2.

We recently added additional logging for this potentially problematic case so that explains why you haven’t seen it before even if nothing has changed in the behavior of your application.

I now realize that there’s one quite harmless case where it could show up and that’s if you’re just making a very big component tree update in one go. Might that be happening in your case?

One thing you could check that could help understand the case better is whether the component always (or often) MultiSelectComboBox or does it vary between many different components between occurrences?

It always has been MultiSelectComboBox so far.

Might a very big component tree update mean MultiSelectComboBox with a lot of items and custom item label generator being attached to UI or user interaction with it?

The observation that it’s always about MultiSelectComboBox makes it unlikely to be caused by a big component tree unless that tree has hundreds of combo boxes and no other complex component.

One possible explanation is that invocations are enqueued for a combo box that is not visible since that prevents the invocations from being delivered. Could this be the case in your application? If that’s the case, then it’s actually a bug on our side but you can work around it by detaching the additional combo boxes instead of only making them (or one of their parent components) invisible.

Another potential cause is if you’re doing fine-grained data provider updates from a background thread. That can potentially cause this condition if done in combination with calling ui.push() manually for each update.

I did not find any cases by your description in our application.

As I was waiting for more logs to come, this happens recently (same warning as before, but with UI component, element body):

`PendingJavaScriptInvocationUtil : 1000 JavaScript invocations scheduled for this UI have not been sent to the browser yet. The most recent one was scheduled for node id=1, element with tag ‘body’, component ‘com.vaadin.flow.component.UI’, com.vaadin.flow.component.UI@74ab71a2 with the expression ‘$0.$connector?.reset()’. The UI has an open push connection, so the invocations are most likely scheduled faster than the browser can consume them. Undelivered invocations are kept in memory until they are sent, so a growing number of them eventually causes an OutOfMemoryError…

The $0.$connector?.reset() invocation targeted at UI might actually also originate from a (multi select) combo box so this might still be the same pattern.

I created 1000 JavaScript invocation warning printed when creating big component tree · Issue #27169 · vaadin/flow · GitHub based on the assumption that this is still triggered by a big component tree.