From 054f16b7bfb7cc6928dd538de3029719591c9ebe Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Thu, 9 Jun 2022 13:14:46 +0200 Subject: [PATCH] fix(client): Network errors during event emission contain the keyword "stream" in Firefox --- src/client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index 8c97ce9d..73d874d5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -733,8 +733,10 @@ async function connect( } } } catch (err) { - // non-network errors shouldn't ever have "network" in the message, right? - error = /network/i.test(err) ? new NetworkError(err) : err; + // non-network errors shouldn't ever have "network" or "stream" in the message, right? + // keyword "network" is for Chrome and keyword "stream" is for Firefox + // TODO: Safari actually completes the stream instead of erroring out, handle that too. + error = /network|stream/i.test(err) ? new NetworkError(err) : err; waitingForThrow?.(error); } finally { Object.values(waiting).forEach(({ proceed }) => proceed());