Skip to content

Commit

Permalink
Fix observeFragment triggering unhandled rejections on network error
Browse files Browse the repository at this point in the history
  • Loading branch information
XiNiHa committed Jan 22, 2025
1 parent 727a9c7 commit b83c4fd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/relay-runtime/store/observeFragmentExperimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import type {
} from 'relay-runtime';

const Observable = require('../network/RelayObservable');
const {getObservableForActiveRequest} = require('../query/fetchQueryInternal');
const {getFragment} = require('../query/GraphQLTag');
const getPendingOperationsForFragment = require('../util/getPendingOperationsForFragment');
const {
handlePotentialSnapshotErrors,
} = require('../util/handlePotentialSnapshotErrors');
Expand Down Expand Up @@ -241,12 +241,12 @@ function snapshotToFragmentState<TFragmentType: FragmentType, TData>(
}

if (snapshot.isMissingData) {
const pendingOperations = getPendingOperationsForFragment(
environment,
fragmentNode,
owner,
);
if (pendingOperations != null) {
if (
getObservableForActiveRequest(environment, owner) != null ||
environment
.getOperationTracker()
.getPendingOperationsAffectingOwner(owner) != null
) {
return {state: 'loading'};
}
}
Expand Down

0 comments on commit b83c4fd

Please sign in to comment.