Skip to content

Return rejected promise instead of throwing it #122

@florello-tbox

Description

@florello-tbox

Expected Behavior

  useAsyncEffect(function* () {
    while (true) {
      try {
        const something = yield Promise.reject(new Error('Something went wrong.'))
        // 2. "something" return the rejected promise, on the second iteration
        debugger
      } catch (err) {
        // 1. catch, happen the first time
        debugger
      }
    }
  }, [])

Should always hit the catch.

Current Behavior

On the first iteration of the loop, yield throw, and it's caught by the try catch. On the second iteration, same code run, but this time something will contain the rejected promise itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions