From 59938cd46b0c4b7a575563480facd4abfee785f0 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Mon, 23 May 2022 10:48:02 -0400 Subject: [PATCH] Handle rate limits when upgrading from a guest account --- src/auth/RegisterPage.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/auth/RegisterPage.jsx b/src/auth/RegisterPage.jsx index d649267..0bdd114 100644 --- a/src/auth/RegisterPage.jsx +++ b/src/auth/RegisterPage.jsx @@ -16,6 +16,8 @@ limitations under the License. import React, { useCallback, useEffect, useRef, useState } from "react"; import { useHistory, useLocation } from "react-router-dom"; +import { captureException } from "@sentry/react"; +import { sleep } from "matrix-js-sdk/src/utils"; import { FieldRow, InputField, ErrorMessage } from "../input/Input"; import { Button } from "../button"; import { useClient } from "../ClientContext"; @@ -81,7 +83,13 @@ export function RegisterPage() { try { await newClient.joinRoom(roomId); } catch (error) { - console.warn(`Couldn't join room ${roomId}`, error); + if (error.errcode === "M_LIMIT_EXCEEDED") { + await sleep(error.data.retry_after_ms); + await newClient.joinRoom(roomId); + } else { + captureException(error); + console.error(`Couldn't join room ${roomId}`, error); + } } } }