Skip to content

docs: document vaadin-server-message and vaadin-ui-terminated events - #6820

Merged
peholmst merged 7 commits into
mainfrom
docs/client-events-server-message
Dec 2, 2026
Merged

peholmst merged 7 commits into
mainfrom
docs/client-events-server-message

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Documents the two other events that window.Vaadin.Flow.clients[appId].events dispatches, next to vaadin-request: vaadin-server-message (vaadin/flow#26305) and vaadin-ui-terminated (vaadin/flow#27058). Both are in 25.4.

Extends the section added in #6566 (merged).

What changed

  • The section is renamed to "Watching Requests and Messages from Page Scripts", and its intro lists all three events.
  • The intro now says that a synthetic vaadin-ui-terminated makes the Flow router stop waiting for a pending navigation. Synthetic vaadin-request and vaadin-server-message events still change nothing in the client.
  • vaadin-server-message: when it fires, the parsed/start/end events of the message, its request and outcome properties, the cases where events are skipped, and an example that measures handling time.
  • vaadin-ui-terminated: when the UI stops, that an embedded web component can start a new UI after "Session expired", and isTerminated().
  • The paragraph on dispatching synthetic events now covers messages too.

Test summary

  • Checked every statement against the Flow client sources (ClientEvents, VaadinServerMessage, UILifecycle, MessageHandler, and the XHR and push connections) on main and 25.4.

Working on behalf of Petter

vaadin-bot and others added 5 commits November 4, 2026 13:55
Add a section to Server to Client Communication describing
window.Vaadin.Flow.clients[appId].events and the vaadin-request event,
through which page scripts can observe each request's delivery
(sent/error/response/end) and dispatch synthetic events for testing.

Documents vaadin/flow#26064 (`3962e2c011fed2b23ed3f3547341980495f0a9ef`).
failure is an object with reason and status, and heartbeats aren't
announced. Show how a page script gets the client, say that listeners
run synchronously, and add the 25.4 since badge.
client.events also announces each message from the server, with its own
parsed, start and end events, and the UI stopping.
Base automatically changed from doc-bot/vaadin-flow/26064-40d33f7ca2134761 to main December 2, 2026 08:50
…rver-message

# Conflicts:
#	articles/flow/advanced/server-client-communication.adoc
@peholmst
peholmst marked this pull request as ready for review December 2, 2026 09:06

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the changes — left 1 comment.

Finding
⚠️ "nothing a page script dispatches on it changes what the client does" is no longer true now that vaadin-ui-terminated is documented

== Watching Requests and Messages from Page Scripts

`window.Vaadin.Flow.clients[appId].events` is an `EventTarget` that announces the requests the client sends to the server, so a page script can follow one, for example to measure it. Heartbeats aren't announced. The client only dispatches on it and never listens to it, so nothing a page script dispatches on it changes what the client does.
`window.Vaadin.Flow.clients[appId].events` is an `EventTarget` that announces the requests the client sends to the server, the messages it receives from the server, and the UI stopping. A page script can follow a request or a message, for example to measure it. Heartbeats aren't announced. The client only dispatches on it and never listens to it, so nothing a page script dispatches on it changes what the client does.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ "nothing a page script dispatches on it changes what the client does" is no longer true now that vaadin-ui-terminated is documented

The intro keeps the blanket claim:

The client only dispatches on it and never listens to it, so nothing a page script dispatches on it changes what the client does.

Flow's own client code does listen on this very EventTarget: flow-client/src/main/frontend/Flow.ts:789 registers events.addEventListener('vaadin-ui-terminated', () => this.settleRoundTrip?.()). A synthetic vaadin-ui-terminated dispatched from a page script therefore settles a pending Flow navigation round trip (Flow.ts:468 and Flow.ts:538).

The claim was harmless while only vaadin-request was documented. Now that the section documents the one event Flow listens to, it should be narrowed, for example: "The client engine only dispatches on it and never listens to it, so a synthetic vaadin-request or vaadin-server-message changes nothing about what it does."

server-client-communication.adoc:82 · accuracy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Narrowed the sentence: synthetic vaadin-request and vaadin-server-message events still change nothing in the client, but a synthetic vaadin-ui-terminated does, because the Flow router listens to it to stop waiting for a pending navigation.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-6820.fly.dev

Changed pages

Added content is highlighted in green; removed content is marked in red on each page.

Built from 66738e4

@peholmst
peholmst merged commit 86f98dd into main Dec 2, 2026
12 of 13 checks passed
@peholmst
peholmst deleted the docs/client-events-server-message branch December 2, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants