You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by li...@apache.org on 2024/03/20 02:40:06 UTC

(incubator-seata-website) branch docusaurus updated: optimize: optimize homepage github api request timeout (#853)

This is an automated email from the ASF dual-hosted git repository.

liuqiufeng pushed a commit to branch docusaurus
in repository https://gitbox.apache.org/repos/asf/incubator-seata-website.git


The following commit(s) were added to refs/heads/docusaurus by this push:
     new b1e7c648c4 optimize: optimize homepage github api request timeout (#853)
b1e7c648c4 is described below

commit b1e7c648c484587355bf26debf6034e1d61de580
Author: liuqiufeng <77...@qq.com>
AuthorDate: Wed Mar 20 10:40:02 2024 +0800

    optimize: optimize homepage github api request timeout (#853)
---
 src/pages/home/top/index.tsx | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/pages/home/top/index.tsx b/src/pages/home/top/index.tsx
index ff70aaa3fe..9154e9a8e4 100644
--- a/src/pages/home/top/index.tsx
+++ b/src/pages/home/top/index.tsx
@@ -37,15 +37,24 @@ const Top = () => {
   });
 
   React.useEffect(() => {
-    fetch('//api.github.com/repos/apache/incubator-seata')
+    const controller = new AbortController();
+    const signal = controller.signal;
+    // set timeout
+    setTimeout(() => {
+      controller.abort();
+    }, 5000);
+
+    fetch('//api.github.com/repos/apache/incubator-seata', { signal })
       .then((res) => res.json())
       .then((data) => {
         setRepo({
           starCount: `${data.stargazers_count}`,
           forkCount: `${data.forks_count}`,
         });
-      });
-    fetch('https://api.github.com/repos/apache/incubator-seata/releases/latest')
+      }).catch((err => {
+        // do nothing
+      }));
+    fetch('https://api.github.com/repos/apache/incubator-seata/releases/latest', { signal })
       .then((res) => res.json())
       .then((data) => {
         setReleaseNote({
@@ -53,7 +62,9 @@ const Top = () => {
           url: data.html_url,
           date: new Date(data.published_at).toLocaleDateString(),
         });
-      });
+      }).catch((err => {
+        // do nothing
+      }));
   }, []);
 
   return (


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org