Stop converting thrown promise to new Error() in react-error-overlay
See original GitHub issueSince suspense had released throwing a promise became so popular and everybody plays with it within create-react-app
environment. When I was trying to create Suspense
with component without using ReactFiber
implementation I’ve faced an issue.
When I throw a promise react-error-overlay
catches it with listeners and converts to new Error()
and overlays my ErrorBoundaries
with its own.
https://github.com/facebook/create-react-app/blob/36ce5786f51f3c793d15178d530d2eb1ae26427a/packages/react-error-overlay/src/effects/unhandledError.js#L13-L26
Here is a sandbox where I’ve reproduced a problem: https://codesandbox.io/s/ww9rxlo15k
Maybe we can ignore thrown promises here and will popup overlay only when error thrown?
As a workaround without ejecting create-react-app
I can remove error listener from window
: https://stackoverflow.com/a/47400249/6717050
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
@cloudever Yes, thats right, only works with 16.3, because there is no
Suspense
inReactFiber
implementation, but if I will switch to 16.6 and implement the same I can’t catch a promise because it get handled during reconciliation. I think it would be great to have an opportunity to create some sort of middleware libraries which could catch a promise and then throw it to the higher layer after doing something with it.I think we don’t need to implement
Suspence
components while they are already exists in reconciler code and works different, than we can expose in code.