You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c5d882b
Browse filesBrowse the repository at this point in the historyBrowse files
fix: run signal effects inline only when session is locked (#27460) (CP: 25.4)
Related to #27187, #27188
**Hardening** · flow-server · signal effects owned by a UI
Signal effects, the signal result notifier and the background change
flag treated "this UI is current" as "this thread holds the session
lock". Flow's request handling now keeps that rule (#27201, #27439).
Code outside Flow can still break it, for example by calling
`UI.setCurrent` without locking the session. Then an effect touched UI
state without the lock and failed with "Cannot access state in
VaadinSession or UI without locking the session". After that, its error
handler failed the same way.
**Risks:**
- ⚠️ Behaviour change, only when the UI is current but its session is
not locked by this thread: the effect, or the result notifier task, is
queued through `UI.access` instead of running right away.
`isBackgroundChange()` reports `true` for that run.
- When the UI is current and locked, which is every normal case, nothing
changes.
- ✅ No new public API. The shared check is
`UIInternals.isCurrentAndLocked()`, which is in the internal package.
The added cost is one `hasLock()` call.
- `ElementEffect`, the result notifier in `VaadinService` and `Effect`'s
background change flag use the new check.
- `guidelines/architecture.md` now describes signal effects as checking
the session lock instead of trusting the current UI.
- Three existing `EffectTest` owner-UI tests now use a plain `UI` with a
mocked session that reports the lock as held, instead of a Mockito `UI`
mock. The owner UI's internals and session lock are now read, and a
Mockito `UI` has no internals. They avoid `MockUI` because it starts a
`VaadinService`, which registers a signal environment that stays active
for the rest of the test class.
- Tests: an effect and a result notifier task triggered while the owner
UI is current but unlocked run later with the lock held, and the effect
reports a background change. Both tests fail without the fix.
Working on behalf of @Artur-
---------
Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: caalador <mikael.grankvist@vaadin.com>
0 commit comments