Skip to content

fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) (CP:24.9) - #25215

Merged
mshabarov merged 1 commit into
24.9from
cherry-pick-25095-to-24.9
Aug 14, 2026
Merged

fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) (CP:24.9)#25215
mshabarov merged 1 commit into
24.9from
cherry-pick-25095-to-24.9

Conversation

@mshabarov

Copy link
Copy Markdown
Contributor

Invocations owned by an invisible component are retained in the UI's queue and get a detach listener registered for them. Registering that listener installs a handler on the invocation itself, and the handler stays attached to the invocation for the rest of its lifetime, since there is no way to unsubscribe it.

A component that keeps the PendingJavaScriptResult and cancels it after being reused in another UI therefore runs the handler installed by the closed UI, which dereferences its cleared session. Return early when the UI no longer has a session, as its invocation queue has already been released by then.

Also release the retained invocations when the UI is closed, so that the queue and the detach listener registrations on the state nodes do not outlive the UI when a detach listener fails and prevents the ones after it from running.

Fixes #25092

(cherry picked from commit 8f059b2)

…25095)

Invocations owned by an invisible component are retained in the UI's
queue and get a detach listener registered for them. Registering that
listener installs a handler on the invocation itself, and the handler
stays attached to the invocation for the rest of its lifetime, since
there is no way to unsubscribe it.

A component that keeps the PendingJavaScriptResult and cancels it after
being reused in another UI therefore runs the handler installed by the
closed UI, which dereferences its cleared session. Return early when the
UI no longer has a session, as its invocation queue has already been
released by then.

Also release the retained invocations when the UI is closed, so that the
queue and the detach listener registrations on the state nodes do not
outlive the UI when a detach listener fails and prevents the ones after
it from running.

Fixes #25092

(cherry picked from commit 8f059b2)
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

1 296 files  ±  0  1 296 suites  ±0   1h 16m 32s ⏱️ + 1m 41s
8 961 tests +  3  8 899 ✅ +  3  62 💤 ±0  0 ❌ ±0 
9 439 runs  +121  9 367 ✅ +118  72 💤 +3  0 ❌ ±0 

Results for commit 91bcd51. ± Comparison against base commit 151daf3.

@tltv tltv changed the title fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) fix: avoid NPE when canceling a JavaScript invocation of a closed UI (#25095) (CP:24.9) Aug 14, 2026
@mshabarov
mshabarov merged commit f8b8a9e into 24.9 Aug 14, 2026
26 checks passed
@mshabarov
mshabarov deleted the cherry-pick-25095-to-24.9 branch August 14, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants