Relay: 馃毃 [Modern] QueryRenderer fetch operation throws uncaught error

Created on 28 Mar 2018  路  9Comments  路  Source: facebook/relay

It looks like in 1.5.0 (https://github.com/facebook/relay/commit/f76f12a56b2ed7486b8d4a0ce5d8efdf206c2b9a), relay-runtime introduced a (pretty major?) bug that manifests as an uncaught exception when handling any Query response that contains GraphQL errors.

RelayObservable.js:644 Uncaught Error: No data returned for operation `MyQuery`, got error(s):
HAHA!

The root cause looks to be that normalizePayload throws errors, and moving that call from the observable map call (which handles errors), to a sink (which doesn't handle errors) prevents relay from catching and handling those errors when thrown.

wontfix

Most helpful comment

any update here?

All 9 comments

cc @dwwoelfel

any update here?

I need a fix for this

does anybody has a repo to reproduce this?

Try this different implementations of executeFunction to see if it helps https://medium.com/@sibelius/relay-modern-network-deep-dive-ec187629dfd3

@sibelius the error sent via reject() from fetchWithRetries that you imported in your Network definition is received properly by QueryRenderer, although it obscures the underlying error from the GraphQL server.

If instead of the fbjs/fetchWithRetries I use fetch, as in the example in https://facebook.github.io/relay/docs/en/quick-start-guide.html then QueryRenderer remains in its "Loading..." state forever on an error from the server. In the QueryRenderer render function, error parameter received is null and an exception is thrown by Relay instead. So, the difference in the error handling between fetch and fetchWithRetries looks to be the key factor.

I am speaking only from my attempt tonight to follow the Relay quick start guide, followed by incorporating your Simplest Network Layer example.

check the implementation of fetchWithRetries here https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/fetch/fetchWithRetries.js#L38

can u create a repo example showing the differences from fetch and fetchWithRetries?

Here's a sample repository illustrating the issue:

https://github.com/ajhyndman/relay-modern-example-issue-2385

image

And another branch illustrating the fix I proposed in #2386.

https://github.com/ajhyndman/relay-modern-example-issue-2385/compare/proposed-fix

image

This one seems to be a glaring issue that has had little attention in checks calendar over two years?

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.

Was this page helpful?
0 / 5 - 0 ratings