Bläddra i källkod

test: add logout debuger

Carson 7 månader sedan
förälder
incheckning
ee794dc534

+ 1 - 1
app/run-agent-flow/components/ASideType/Agent.tsx

@@ -122,7 +122,7 @@ const Agent = ({ node, asideInstantAtom }) => {
   }
 
   const onStop = async () => {
-    ctrlRef.current?.abort()
+    ctrlRef.current?.abort(null)
   }
 
   const effectButtons = []

+ 1 - 1
app/run-agent-flow/components/ASideType/Form.tsx

@@ -63,7 +63,7 @@ const Form = ({ node, asideInstantAtom }) => {
   }
 
   const onStop = async () => {
-    ctrlRef.current?.abort()
+    ctrlRef.current?.abort(null)
   }
 
 

+ 2 - 1
app/run-agent-flow/components/Header.tsx

@@ -17,7 +17,8 @@ export default function Header() {
     const res = await fetch("https://beta.api.cocorobo.cn/api/logout", {
       method: "POST", credentials: 'include'
     });
-    await signOut({ redirect: false })
+    const res1 = await signOut({ redirect: false })
+    debugger
   }
 
   return (

+ 6 - 9
lib/utils.ts

@@ -70,13 +70,11 @@ export function getChatResponse({
     };
 
     ctrl.signal.addEventListener("abort", (e) => {
-      // FIXME
-      // if (e?.target?.reason?.message) {
-      //   error = e.target.reason
-      // } else {
-      //   done = true
-      // }
-      done = true;
+      if (e?.target?.reason) {
+        error = new Error(e.target.reason);
+      } else {
+        done = true;
+      }
       resolveQueuePromise();
       eventSource.close();
     });
@@ -95,8 +93,7 @@ export function getChatResponse({
       }
       // every looping stream, we wait for 10s
       timer = setTimeout(() => {
-        error = new Error("SSE timeout aborted.");
-        ctrl.abort();
+        ctrl.abort("SSE timeout aborted.");
       }, 10000);
       if (queue.length > 0) {
         yield queue.shift();