← Back to Pull requests

fix(reactive)!: don't call poll_func when @poll() is applied #2576

Closed
unknown closed this pull request without merging on Nov 25, 2026 21:41 UTC
View on GitHub
unknown unknown commented on Oct 21, 2026 09:36 UTC
Author

reactive.poll() accepts an async poll_func (the docstring says "Both regular functions and co-routine functions are allowed", and the polling effect awaits it). But poll() seeded its last value with reactive.Value(poll_func()), so for an async function that value was a coroutine object that is never awaited.

The first run of the polling effect then called equals(old, new) with that coroutine as old. With the default == this is just "not equal", but a custom equals that reads the value, for example lambda old, new: old["version"] == new["version"], raises. poll() turns that into its "couldn't be compared with a previously returned object" TypeError and stores it. Because the last value is only replaced after a successful comparison, every later poll fails the same way, and the data never loads.

Change. For both async and sync poll_func, the last value now starts unset; poll_func is not called when @poll() is applied. The polling effect reads the first value and stores it without calling equals.

  • Until the first poll, reading the decorated function raises a silent exception, and its readers run again once the value is set. With a sync poll_func the polling effect (priority=1 by default) sets the value before outputs render, so outputs see data on their first render, as before. With an async poll_func that waits on I/O, outputs stay empty until it returns.

  • poll_func runs one fewer time per session, since the setup call is gone. test_poll expects one fewer poll_func call at each step; the value_func counts are unchanged.

  • reactive.file_reader() with a missing file no longer raises when the decorator is applied. The FileNotFoundError is raised when the value is read, and the next poll recovers once the file exists.
  • Breaking change. Reading a @poll() or @file_reader() value outside the reactive runtime before the first poll, for example in reactive.isolate() while the server function runs, now raises a silent exception instead of returning the value. Reads from outputs, calcs, and effects wait for the first poll. CHANGELOG.md lists this under breaking changes.

    The model-score example did this: its deduplicate() helper read a calc built on @poll() inside reactive.isolate() while the server function ran, so the first session after the server started never finished starting. deduplicate() now starts its value unset and lets its effect set it.

    Tests.

  • test_poll_async_poll_func_with_custom_equals: an async poll_func with an equals that reads a key. Nothing is polled when @poll() runs, and the value can be read after the first poll and after the next interval.

  • test_poll_reader_runs_before_first_poll (sync and async): a reader that runs before the polling effect waits for the first poll and doesn't make the read function run twice.

  • test_poll_first_poll_raises: when the first poll raises, readers get that error, not a silent exception, and a later good poll recovers.

  • test_file_reader_missing_file: the missing-file behavior above.
  • This change was made with Claude Code.

    Diff: 391 lines (+293 / -98) across 4 files Reviewer: pcbeingused333 Review duration: 51125m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 391 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.357
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2576"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.1% (MEDIUM) · Higher = larger blast radius
    43.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17% · Safe to merge
    17%