Open azz opened 3 years ago
Can you share your network layer code?
Here is a cut-down version of fetchQuery
:
function fetchQuery(operation, variables) {
return fetch('/graph', {
method: 'POST',
headers: {},
body: JSON.stringify({ query: operation.text, variables }),
}).then(async response => {
if (!response.ok) {
throw new Error('oh no!');
}
const json = await response.json();
return json;
});
}
I hit the same problem. My reproduction code is here: https://codesandbox.io/s/ecstatic-sanne-dqyeo?file=/src/TodoApp.tsx
Also ran into this error, I expected the error boundary to be hit but the suspended app resolves and tries to render instead.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
bad stalebot
I'm hitting the same error as well. An error thrown from inside the fetchQuery function, isn't getting caught by the error boundary. Instead it is trying to render the Fragment and throwing an error "Uncaught TypeError: Cannot read properties of undefined (reading 'name')".
@abilash-arista using UNSTABLE_renderPolicy: 'full'
or React concurrent mode should work around this issue, more details in #4146
@abilash-arista using
UNSTABLE_renderPolicy: 'full'
or React concurrent mode should work around this issue, more details in #4146
@levibuzolic Awesome, thanks for pointing me to the correct issue! Using React concurrent mode fixed it for me.
Say I have a container component which just spreads fragments (i.e., does not suspend):
And then a fragment component:
When
Component
is rendered, it suspends correctly, however if thefetchQuery
promise forContainerQuery
rejects with an error, instead of that error being propagated from theuseFragment
callsite, theuseFragment
returns an empty dataset (e.g.viewer
isundefined
above).There are two issues here:
fetchQuery
error is silently ignored.useFragment
does not match its flow type (viewer
is not nullable).