Skip to content

Commit dd14a05

Browse files
committed
Make unsubscribing graceful
1 parent cc24d0f commit dd14a05

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/app/src/app/overmind/dependencies/overmind-graphql.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ export const graphql: <T extends Queries>(
202202

203203
subscription.dispose = () => {
204204
_subscriptions[queryString].forEach(sub => {
205-
sub.dispose();
205+
try {
206+
sub.dispose();
207+
} catch (e) {
208+
// Ignore, it probably throws an error because we weren't subscribed in the first place
209+
}
206210
});
207211
_subscriptions[queryString].length = 0;
208212
};
@@ -212,6 +216,11 @@ export const graphql: <T extends Queries>(
212216
Subscription[]
213217
>((subAggr, sub) => {
214218
if (cb(sub.variables)) {
219+
try {
220+
sub.dispose();
221+
} catch (e) {
222+
// Ignore, it probably throws an error because we weren't subscribed in the first place
223+
}
215224
return subAggr;
216225
}
217226
return subAggr.concat(sub);

0 commit comments

Comments
 (0)