From 59cc7e8c76a975cfce11af0ab5886b499201c6a3 Mon Sep 17 00:00:00 2001 From: davwas Date: Wed, 6 Mar 2024 16:06:34 +0100 Subject: [PATCH] BC-6709 - Whiteboard crash fixes (#65) * add new error case --- src/hooks/useWebsocketErrorHandler.ts | 8 ++++++++ src/types/StatusCodeEnums.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/hooks/useWebsocketErrorHandler.ts b/src/hooks/useWebsocketErrorHandler.ts index 878b0fe9..1bbaf2a6 100644 --- a/src/hooks/useWebsocketErrorHandler.ts +++ b/src/hooks/useWebsocketErrorHandler.ts @@ -21,6 +21,11 @@ const websocketErrors = [ httpCode: HttpStatusCode.NotFound, translationMessageKey: "tldraw.error.ws.4404", }, + { + websocketCode: WebsocketStatusCode.NotAcceptable, + httpCode: HttpStatusCode.NotAcceptable, + translationMessageKey: "tldraw.error.ws.4406", + }, { websocketCode: WebsocketStatusCode.InternalServerError, httpCode: HttpStatusCode.InternalServerError, @@ -35,6 +40,9 @@ export function useWebsocketErrorHandler() { (element) => element.websocketCode === event.code, ); if (!error) return; + // not acceptable means we have to wait for the server to accept us + // keep reconnecting + if (error.websocketCode === WebsocketStatusCode.NotAcceptable) return; setErrorData(error.httpCode, error.translationMessageKey); redirectToErrorPage(); diff --git a/src/types/StatusCodeEnums.ts b/src/types/StatusCodeEnums.ts index d870a959..9b222403 100644 --- a/src/types/StatusCodeEnums.ts +++ b/src/types/StatusCodeEnums.ts @@ -4,6 +4,7 @@ export enum HttpStatusCode { Unauthorized = 401, Forbidden = 403, NotFound = 404, + NotAcceptable = 406, InternalServerError = 500, } @@ -11,5 +12,6 @@ export enum WebsocketStatusCode { BadRequest = 4400, Unauthorized = 4401, NotFound = 4404, + NotAcceptable = 4406, InternalServerError = 4500, }