Skip to content

2.0.0-beta.15 Errors in reactive reads always progagate even if handled logically #2802

Description

@dangkyokhoang

Describe the bug

  1. When reading a reactive value that throws, the error propagate to dependents and dependents are marked with STATUS_ERROR without re-running dependent compute functions. So even if a dependent compute function handles the error, it is still marked as errored.
  2. Reads inside async memo compute fn, after recovered from the error, are stale.

Your Example Website or App

https://stackblitz.com/edit/nitrojs-nitro-1w8mivtu?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the example
  2. Click Increment, both syncDerived and syncDerivedStringified errored, async* doesn't update.
  3. Click Increment again, sync* recovers, async* errored with stale reads.

Expected behavior

Errors should not propagate to dependents directly but go through dependent compute functions to allow error handling.

If the current behavior is by design, then how can I depend on a reactive value without the risk of error propagating? For example, disabling a reset button when resetting, inside <Errored fallback>:

<Errored fallback={(err, reset) => <button onClick={reset} disabled={isPending(data)}>Reset</button>}>
...
</Errored>

Screenshots or Videos

No response

Platform

Any

Additional context

Relevant discussion: #2791

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions