load error is no op
This commit is contained in:
@@ -95,6 +95,7 @@ export default function SearchRoutePage() {
|
||||
streamAbortRef.current?.abort();
|
||||
const abortController = new AbortController();
|
||||
streamAbortRef.current = abortController;
|
||||
let wasInterrupted = false;
|
||||
setError(null);
|
||||
setIsRunning(true);
|
||||
|
||||
@@ -177,7 +178,10 @@ export default function SearchRoutePage() {
|
||||
},
|
||||
onAnswerError: (payload) => {
|
||||
if (requestId !== requestCounterRef.current) return;
|
||||
if (isInterruptedStreamError(payload.error)) return;
|
||||
if (isInterruptedStreamError(payload.error)) {
|
||||
wasInterrupted = true;
|
||||
return;
|
||||
}
|
||||
setSearch((current) => (current ? { ...current, answerError: payload.error } : current));
|
||||
},
|
||||
onDone: (payload) => {
|
||||
@@ -186,23 +190,32 @@ export default function SearchRoutePage() {
|
||||
},
|
||||
onError: (payload) => {
|
||||
if (requestId !== requestCounterRef.current) return;
|
||||
if (isInterruptedStreamError(payload.message)) return;
|
||||
if (isInterruptedStreamError(payload.message)) {
|
||||
wasInterrupted = true;
|
||||
return;
|
||||
}
|
||||
setError(payload.message);
|
||||
},
|
||||
},
|
||||
{ signal: abortController.signal }
|
||||
);
|
||||
} catch (err) {
|
||||
if (abortController.signal.aborted) return;
|
||||
if (abortController.signal.aborted) {
|
||||
wasInterrupted = true;
|
||||
return;
|
||||
}
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
if (isInterruptedStreamError(message)) return;
|
||||
if (isInterruptedStreamError(message)) {
|
||||
wasInterrupted = true;
|
||||
return;
|
||||
}
|
||||
if (message.includes("bearer token")) {
|
||||
handleAuthFailure(message);
|
||||
} else if (requestId === requestCounterRef.current) {
|
||||
setError(message);
|
||||
}
|
||||
} finally {
|
||||
if (requestId === requestCounterRef.current) {
|
||||
if (requestId === requestCounterRef.current && !wasInterrupted) {
|
||||
streamAbortRef.current = null;
|
||||
setIsRunning(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user