Skip to content

Commit

Permalink
Replace invariant in SuspenseResource with the warning in the case wh…
Browse files Browse the repository at this point in the history
…ere GC is disabled

Reviewed By: alunyov

Differential Revision: D52667902

fbshipit-source-id: 001d74bdfd6dddf57e1762f9b4edf0ceb12f780b
  • Loading branch information
monicatang authored and facebook-github-bot committed Jan 12, 2024
1 parent 0c4a191 commit d90dedf
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/react-relay/relay-hooks/SuspenseResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import type {Disposable, IEnvironment} from 'relay-runtime';

const invariant = require('invariant');
const warning = require('warning');

const TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;

Expand All @@ -38,13 +38,16 @@ class SuspenseResource {
dispose: () => {
this._retainCount = Math.max(0, this._retainCount - 1);
if (this._retainCount === 0) {
invariant(
this._retainDisposable != null,
'Relay: Expected disposable to release query to be defined.' +
"If you're seeing this, this is likely a bug in Relay.",
);
this._retainDisposable.dispose();
this._retainDisposable = null;
if (this._retainDisposable != null) {
this._retainDisposable.dispose();
this._retainDisposable = null;
} else {
warning(
false,
'Relay: Expected disposable to release query to be defined.' +
"If you're seeing this, this is likely a bug in Relay.",
);
}
}
},
};
Expand Down

0 comments on commit d90dedf

Please sign in to comment.