Skip to content

2.0.0-beta.15 | Error thrown by async read in <Loading> is not captured by a wrapping <Errored> #2821

Description

@mizulu

Describe the bug

Error thrown by async read in is not captured by a wrapping

Image
   <div>
        A <Loading fallback={()=>"Loading...1"}>
          <Errored fallback={()=>"Error 1"}>{asyncMemo()}</Errored>
        </Loading>
      </div>

      <hr />

      <div>
        B <Errored fallback={()=>"Error 2"}>
          <Loading fallback={()=>"Loading...2"}>
            {asyncMemo()}
          </Loading>
        </Errored>
      </div>

Your Example Website or App

https://s.olid.uk/id/u7y7YIokR4m6nTge0V5B2w

Steps to Reproduce the Bug or Issue

case 2 is a control case, where both cases actually works more as expected and shows the errored fallback.

  /**
   * Case 1: 
   * refresh preview 
   * 
   * 1. wait for initial load 
   * A  Loading...1  => A 0 
   * B  Loading...2  => B 0 
   * 
   * 2. click The button once 
   * Expected: 
   *   A  0 => Error 1 
   *   B  0 => Error 2  
   * 
   * Actual : 
   *   A  0 => Error 1 
   *   B  0 => 0 
   * Console logs: 
   * ✖ ERRRR 
   * 
   * in this case only the first case went through the fallback.
   * 
   * Case 2 
   * refresh preview 
   *  1. click the button once before the promise resolve 
   * 
   * render will change from => to  
   * A Loading...1 => A Error 1 
   * B Loading...1 => B Error 2 
   * Console logs: 
   * ✖ ERRRR 
   * ✖ ERRRR
   * 
   * In this case both fallbacks worked 
   * 
   */

Expected behavior

both <Errored><Loading>{asyncReadThatErrors()}</Loading></Errored>
and <Loading><Errored>{asyncReadThatErrors()}</Errored></Loading>

should fallback to error if there was an error in the async read.

Screenshots or Videos

No response

Platform

.

Additional context

verify that this is fixed by recent related fixes
#2809

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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