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