Created
January 5, 2021 22:22
-
-
Save jasonLaster/73b610bde300ea6e50c5ef58ad18ac90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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