Skip to content

Commit

Permalink
fix(client): Network errors during event emission contain the keyword…
Browse files Browse the repository at this point in the history
… "stream" in Firefox
  • Loading branch information
enisdenjo committed Jun 9, 2022
1 parent 3f516d7 commit 054f16b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,10 @@ async function connect<SingleConnection extends boolean>(
}
}
} 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());
Expand Down

0 comments on commit 054f16b

Please sign in to comment.