Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ CompletableFuture<Map<String, Person>> future = getElement()
----


[#undelivered-invocations]
[role="since:com.vaadin:vaadin@V25.3"]
== Undelivered Invocations

An invocation scheduled on the server is held in memory until it's written into a response for the browser. An application that keeps scheduling invocations which never reach the browser grows until it runs out of memory. Once 1000 invocations for one UI are waiting to be sent, Flow logs a warning naming the component they belong to, the expression of the most recent one, and why nothing is being delivered. The warning is logged once per UI.

Invocations pile up whenever nothing carries them to the browser:

- *The owner is detached.* An invocation for a detached element is held until that element is attached again, which never happens for a component the application has discarded.
- *The owner is invisible.* Invocations for an invisible component are kept until it becomes visible.
- *The UI has no open push connection.* Nothing is sent until the browser makes a request of its own, which a closed tab whose session hasn't expired yet never does.

Where only the latest value matters -- a progress value, a clock, a live measurement -- avoid scheduling a new invocation for every update:

- Keep the [classname]`PendingJavaScriptResult` that [methodname]`executeJs()` returns, and call [methodname]`cancelExecution()` on it before scheduling the next one.
- Set an element property with [methodname]`Element.setProperty()` instead. Only the last value of a property is sent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems not clear to me how element properties are related to pending JavaScript invocation. Do we have documentation that suggests setting properties via JavaScript?

- In a background task, compare [methodname]`UI.getLastUpdateSentTimestamp()` against the current time and stop scheduling updates while the browser isn't receiving them.


[[js-function]]
[role="since:com.vaadin:vaadin@V25.2"]
== Passing JavaScript Functions
Expand Down
6 changes: 6 additions & 0 deletions articles/flow/production/troubleshooting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ This mean the value from one application is overridden by another. To resolve th
See https://datatracker.ietf.org/doc/html/rfc6265#section-8.5[HTTP State Management Mechanism RFC] for more information.


The application runs out of memory, and the heap holds a large number of pending JavaScript invocations.::
JavaScript scheduled from the server with [methodname]`executeJs()` is kept in memory until it's written into a response for the browser, so an application that keeps scheduling invocations which are never delivered grows until it fails. Flow logs a warning once 1000 invocations for one UI are waiting to be sent, naming the component they belong to and why nothing is being delivered.
+
See <<{articles}/flow/component-internals/element-api/calling-javascript#undelivered-invocations, Undelivered Invocations>> for the causes and for what to do instead.


[discussion-id]`9A4AD367-94A0-4933-AE09-1A08016E6E58`
Loading