Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created January 5, 2021 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/73b610bde300ea6e50c5ef58ad18ac90 to your computer and use it in GitHub Desktop.
Save jasonLaster/73b610bde300ea6e50c5ef58ad18ac90 to your computer and use it in GitHub Desktop.
diff --git a/src/protocol/socket.ts b/src/protocol/socket.ts
index ae5d602c..044b3f10 100644
--- a/src/protocol/socket.ts
+++ b/src/protocol/socket.ts
@@ -1,5 +1,6 @@
import { defer, makeInfallible } from "./utils";
import { ProtocolClient } from "@recordreplay/protocol";
+import { setExpectedError } from "ui/actions/session";
interface Message {
id: number;
@@ -28,12 +29,12 @@ const gStartTime = Date.now();
let gSentBytes = 0;
let gReceivedBytes = 0;
-export function initSocket(address?: string) {
+export function initSocket(store, address?: string) {
socket = new WebSocket(address || "wss://dispatch.replay.io");
socket.onopen = makeInfallible(onSocketOpen);
socket.onclose = makeInfallible(onSocketClose);
- socket.onerror = makeInfallible(onSocketError);
+ socket.onerror = makeInfallible(() => store.dispatch(onSocketError()));
socket.onmessage = makeInfallible(onSocketMessage);
}
@@ -116,7 +117,10 @@ function onSocketClose() {
}
function onSocketError() {
- log("Socket Error");
+ return ({ dispatch }) => {
+ log("Socket Error");
+ dispatch(setExpectedError);
+ };
}
export function log(text: string) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment