From f4ec21cc036b1c68f1b61bbb67b506ab2ef21590 Mon Sep 17 00:00:00 2001 From: Matthew Cullum Date: Mon, 2 Aug 2021 15:02:41 -0700 Subject: [PATCH] Implement a fix for the "ERROR Error: Observable cancelled prematurely" bug https://github.com/apollographql/apollo-client/issues/7608#issuecomment-882418482 --- src/utilities/observables/Concast.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/observables/Concast.ts b/src/utilities/observables/Concast.ts index 0126650b051..bcc8e4f7b82 100644 --- a/src/utilities/observables/Concast.ts +++ b/src/utilities/observables/Concast.ts @@ -178,7 +178,7 @@ export class Concast extends Observable { // Delay unsubscribing from the underlying subscription slightly, // so that immediately subscribing another observer can keep the // subscription active. - if (sub) Promise.resolve().then(() => sub.unsubscribe()); + if (sub) setTimeout(()=>{sub.unsubscribe()}, 0) this.sub = null; this.latest = ["error", error]; this.reject(error);