Skip to content

Commit d90dedf

Browse files
monicatangfacebook-github-bot
authored andcommitted
Replace invariant in SuspenseResource with the warning in the case where GC is disabled
Reviewed By: alunyov Differential Revision: D52667902 fbshipit-source-id: 001d74bdfd6dddf57e1762f9b4edf0ceb12f780b
1 parent 0c4a191 commit d90dedf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/react-relay/relay-hooks/SuspenseResource.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

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

16-
const invariant = require('invariant');
16+
const warning = require('warning');
1717

1818
const TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;
1919

@@ -38,13 +38,16 @@ class SuspenseResource {
3838
dispose: () => {
3939
this._retainCount = Math.max(0, this._retainCount - 1);
4040
if (this._retainCount === 0) {
41-
invariant(
42-
this._retainDisposable != null,
43-
'Relay: Expected disposable to release query to be defined.' +
44-
"If you're seeing this, this is likely a bug in Relay.",
45-
);
46-
this._retainDisposable.dispose();
47-
this._retainDisposable = null;
41+
if (this._retainDisposable != null) {
42+
this._retainDisposable.dispose();
43+
this._retainDisposable = null;
44+
} else {
45+
warning(
46+
false,
47+
'Relay: Expected disposable to release query to be defined.' +
48+
"If you're seeing this, this is likely a bug in Relay.",
49+
);
50+
}
4851
}
4952
},
5053
};

0 commit comments

Comments
 (0)