Uncaught exceptions in updaters cause relay store to break
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
When an exception or error is thrown in an updater function, the relay store, (Im not sure how else to put this) basically just breaks from then on. Subsequent queries for example start to break and error, and I start seeing warnings in the console saying
```
A store update was detected within another store update. Please make sure new store updates aren't being executed within an updater function for a different update.
```
The repro for this is pretty simple, just invoke:
```
commitLocalUpdate(environment, () => {
throw new Error("Break me");
})
```
And then try to render say a `QueryRenderer` or trigger a query. Those queries start to all fail, and the error in each is the error thrown. It seems like if any exception is unhandled within an updater, the entire relay store breaks.
Curious if this is known/expected, and reasoning if so?
### Reproduciton
Sorry, its a bit tough to get a codesandbox running with relay (well i kept hitting issues, but I checked locally with my project running relay 15 as well as this forked sandbox of a react relay starter project, both exhibit the same behavior).
The following codesandbox contains some other relay version from that original fork, but the behavior seems to be the same.
https://codesandbox.io/s/gallant-mountain-c25wc2?file=/src/App.js
Just click the first button, this triggers the local update and throws the error, then click the 2nd button, which renders a query component and you'll see it catches. If you only press the 2nd button, the query displays fine.
Relay Version Used: `15.0.0`, though it can repro on other versions
React Version: `17`.
Contributor guide
Assessment
This issue has not been assessed yet.