Skip to content

Commit

Permalink
BC-6709 - Whiteboard crash fixes (#65)
Browse files Browse the repository at this point in the history
* add new error case
  • Loading branch information
davwas authored Mar 6, 2024
1 parent f34d295 commit 59cc7e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hooks/useWebsocketErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/types/StatusCodeEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ export enum HttpStatusCode {
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
NotAcceptable = 406,
InternalServerError = 500,
}

export enum WebsocketStatusCode {
BadRequest = 4400,
Unauthorized = 4401,
NotFound = 4404,
NotAcceptable = 4406,
InternalServerError = 4500,
}

0 comments on commit 59cc7e8

Please sign in to comment.