From f096a5682bfaad5a302fe80c517a77ceac460244 Mon Sep 17 00:00:00 2001 From: Eugene Fox Date: Wed, 9 Oct 2024 14:15:09 +0000 Subject: [PATCH] fix: fixed possibe requrest timeout for AlertMessage --- app/_components/AlertMessage.tsx | 35 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/_components/AlertMessage.tsx b/app/_components/AlertMessage.tsx index 3da3b9c..d78e754 100644 --- a/app/_components/AlertMessage.tsx +++ b/app/_components/AlertMessage.tsx @@ -18,24 +18,31 @@ const AlertMessage: React.FC = async () => if (!process.env.ALERT_TEXT_URL) return null; - const response: Response = await fetch(process.env.ALERT_TEXT_URL, { cache: "no-cache" }); - const alertText: string = await response.text(); + try + { + const response: Response = await fetch(process.env.ALERT_TEXT_URL, { cache: "no-cache" }); + const alertText: string = await response.text(); - if (!response.ok || !alertText) - return null; + if (!response.ok || !alertText) + return null; - const title: string = alertText.split("\n", 1)[0]; - const message: string = alertText.substring(title.length); + const title: string = alertText.split("\n", 1)[0]; + const message: string = alertText.substring(title.length); - return ( -
- -
-

{ title }

-

+ return ( +

+ +
+

{ title }

+

+

-
- ); + ); + } + catch + { + return null; + } }; export default AlertMessage;