attempt to suppress answer errors on search route
This commit is contained in:
@@ -23,6 +23,17 @@ function pushSearchQuery(query: string) {
|
||||
window.history.pushState({}, "", next);
|
||||
}
|
||||
|
||||
function isInterruptedStreamError(message: string | null | undefined) {
|
||||
if (!message) return false;
|
||||
const normalized = message.toLowerCase();
|
||||
return (
|
||||
normalized.includes("abort") ||
|
||||
normalized.includes("interrupted") ||
|
||||
normalized.includes("cancelled") ||
|
||||
normalized.includes("canceled")
|
||||
);
|
||||
}
|
||||
|
||||
export default function SearchRoutePage() {
|
||||
const {
|
||||
authTokenInput,
|
||||
@@ -164,6 +175,7 @@ export default function SearchRoutePage() {
|
||||
},
|
||||
onAnswerError: (payload) => {
|
||||
if (requestId !== requestCounterRef.current) return;
|
||||
if (isInterruptedStreamError(payload.error)) return;
|
||||
setSearch((current) => (current ? { ...current, answerError: payload.error } : current));
|
||||
},
|
||||
onDone: (payload) => {
|
||||
@@ -172,6 +184,7 @@ export default function SearchRoutePage() {
|
||||
},
|
||||
onError: (payload) => {
|
||||
if (requestId !== requestCounterRef.current) return;
|
||||
if (isInterruptedStreamError(payload.message)) return;
|
||||
setError(payload.message);
|
||||
},
|
||||
},
|
||||
@@ -180,6 +193,7 @@ export default function SearchRoutePage() {
|
||||
} catch (err) {
|
||||
if (abortController.signal.aborted) return;
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
if (isInterruptedStreamError(message)) return;
|
||||
if (message.includes("bearer token")) {
|
||||
handleAuthFailure(message);
|
||||
} else if (requestId === requestCounterRef.current) {
|
||||
|
||||
Reference in New Issue
Block a user