Skip to content

Throw error when using signal.get() inside bindChildren callback#23845

Open
Artur- wants to merge 5 commits intomainfrom
feature/bindchildren-signal-get-error
Open

Throw error when using signal.get() inside bindChildren callback#23845
Artur- wants to merge 5 commits intomainfrom
feature/bindchildren-signal-get-error

Conversation

@Artur-
Copy link
Member

@Artur- Artur- commented Mar 12, 2026

Wrap the child factory callback in bindChildren with a UsageTracker deny-registrar that throws DeniedSignalUsageException when signal.get() is called directly. This prevents accidental eager reads that create unwanted dependencies at the effect level instead of per-component reactive bindings.

Users should use peek() for one-time reads or pass the signal to a component that creates its own reactive binding
(e.g. new Span(() -> signal.get())).

Fixes #23841

Wrap the child factory callback in bindChildren with a
UsageTracker deny-registrar that throws DeniedSignalUsageException
when signal.get() is called directly. This prevents accidental
eager reads that create unwanted dependencies at the effect level
instead of per-component reactive bindings.

Users should use peek() for one-time reads or pass the signal to
a component that creates its own reactive binding
(e.g. new Span(() -> signal.get())).

Fixes #23841
@Artur- Artur- requested a review from Legioth March 12, 2026 09:09
@github-actions
Copy link

github-actions bot commented Mar 12, 2026

Test Results

 1 384 files  ±0   1 384 suites  ±0   1h 33m 40s ⏱️ + 2m 28s
 9 906 tests +1   9 783 ✅  - 51  71 💤 ±0  9 ❌ +9  43 🔥 +43 
10 379 runs  +1  10 245 ✅  - 53  80 💤 ±0  9 ❌ +9  45 🔥 +45 

For more details on these failures and errors, see this check.

Results for commit bc91323. ± Comparison against base commit 6a63221.

♻️ This comment has been updated with latest results.

Artur- added 4 commits March 12, 2026 16:05
Propagate DeniedSignalUsageException immediately to the caller
instead of routing it through the session error handler. This gives
developers an immediate stack trace at the call site when they
mistakenly use signal.get() inside a bindChildren child factory.

- ElementEffect.executeAction: catch DeniedSignalUsageException
  separately and re-throw before the general RuntimeException handler
- Effect constructor: re-throw RuntimeExceptions on first run so
  they propagate out of the synchronous initial execution
- Update test to use assertThrows instead of error handler assertion
Replace the broad first-run RuntimeException re-throw with a
targeted catch for DeniedSignalUsageException. The previous
approach broke EffectTest because it re-threw all RuntimeExceptions
on first run, but raw Effect usage expects exceptions to be routed
to the uncaught exception handler even on the initial run.
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throw an error if using signal.get() directly inside bindChildren callback

2 participants