Relay: Relay container suspends when not using `@defer` or `@module`.

Created on 28 Jan 2020  路  4Comments  路  Source: facebook/relay

After updating to Relay v8, we started getting this error in a few places in our code. We are not using @defer or @module or any code from react-relay/hooks.

Relay Container for fragment `xyz` suspended. When using features such as @defer or @module, use `useFragment` instead of a Relay Container.

The underlying issue was that a component was being rendered while its data was missing from the store.

I traced it back to this condition: https://github.com/facebook/relay/blob/b931d0b1961cd04580d7f019ed3a0be9818f1ea6/packages/relay-runtime/store/RelayModernFragmentSpecResolver.js#L246

When the error occurs, isMissingData is true, but also getPromiseForRequestInFlight returns a promise, because sink.complete() was not yet called for the request.

It appears that this condition is checked synchronously after sink.next(value) here: https://github.com/facebook/relay/blob/b931d0b1961cd04580d7f019ed3a0be9818f1ea6/packages/relay-runtime/network/RelayObservable.js#L465-L466, but before sink.complete() is called on the next line.

Is this expected behavior? In Relay v7 the missing data would be handled gracefully.

bug

Most helpful comment

this was causing some component flickering so we disabled it via a quick & dirty hack:

import RelayFeatureFlags from 'relay-runtime/lib/util/RelayFeatureFlags'
RelayFeatureFlags.ENABLE_RELAY_CONTAINERS_SUSPENSE = false

All 4 comments

this was causing some component flickering so we disabled it via a quick & dirty hack:

import RelayFeatureFlags from 'relay-runtime/lib/util/RelayFeatureFlags'
RelayFeatureFlags.ENABLE_RELAY_CONTAINERS_SUSPENSE = false

this still happening on v9

still happening here on v9, for now I am using @mattkrick solution!!

thanks for reporting this and apologies for the delay, we'll change the default value of that flag, it should't be on by default

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgwilym picture sgwilym  路  4Comments

mike-marcacci picture mike-marcacci  路  3Comments

jstejada picture jstejada  路  3Comments

MartinDawson picture MartinDawson  路  3Comments

janicduplessis picture janicduplessis  路  3Comments