I think the more interesting part is the two classes mentioned above. OperatorMainPage seems to be captured in the error handler lambda, and it keeps OperatorMainView instance bound to the VaadinSession.
My suspicion is that there’s something in those classes that is directly or indirectly calling executeJs (or similar) repeatedly.
Code of OperatorMainPage might contain something. Maybe also the exact code that registers the error handler. I guess the previously posted snippet is just a modified excerpt, because it does not show any captured instance.
Please also inspect the PendingJavaScriptInvocation in the dump to understand what JS expression they are referring to (PendingJavaScriptInvocation → invocation (JavaScriptInvocation ) → expression (String))
But also setting the error handler in the constructor of OperatorMainPage does not seem a good practice. You are replacing the error handle every time you create a view for the same session,
So if you open the same page in two tabs, you will replace the session error handler with the one from the last created UI
If almost all expressions are return (async function() { this.invalid = $0}).apply($1) something could be repeatedly calling setInvalid(...) on detached components
This is just a guess since without the opportunity to see the real code it’s impossible to know what is happening.
It is likely that pending js invocation (the expression in the screenshot) is enqueue because something is calling the setInvalid method on a component that is currently detached from the UI. The invocation stays pending until the component is attached.
If all pending invocation are referencing the same js expression, it could be that something (a background thread?) is repeatedly calling setInvalid on detached components, thus continously enqueing js invocations that get never cleaned.
The error handler keeping the view alive and bound to the session could be one of the causes.
You need to investigate and understand if setInvalid is effectively called indefinitely and if so who is calling it.
Then you need to check if the component is detached.
Yes, setInvalid called on a Vaadin component. The method is defined on a mixin interface (HasXyx, I don’t remember the exact name right now). Put a breakpoint there
Hi,
I have about 780.000 instances of com.vaadin.flow.internal.StateTree$BeforeClientResponseEntry and about the same amount of com.vaadin.flow.component.internal.PendingJavaScriptInvocation objects.
Do you think this could be caused by stale Vaadin sessions? Is it possible that the server does not notice when the browser is closed, and continues to send updates to the browser that accumulate?
It’s really hard to say without knowing how the application works. VaadinSession is bound to the HTTP session life cycle so they are usually destroyed when the session expires. UIs are also usually closed if they are inactive (see How to manage the Vaadin application lifecycle).
I think you need to carefully analyze the heap dumps and try to detect who is keeping the pending Javascript invocation alive (closed UIs? detached components referenced by other classes?) and also as said before identify which components are scheduling the js invocation and where/how they are used in the application.