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);
|
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() {
|
export default function SearchRoutePage() {
|
||||||
const {
|
const {
|
||||||
authTokenInput,
|
authTokenInput,
|
||||||
@@ -164,6 +175,7 @@ export default function SearchRoutePage() {
|
|||||||
},
|
},
|
||||||
onAnswerError: (payload) => {
|
onAnswerError: (payload) => {
|
||||||
if (requestId !== requestCounterRef.current) return;
|
if (requestId !== requestCounterRef.current) return;
|
||||||
|
if (isInterruptedStreamError(payload.error)) return;
|
||||||
setSearch((current) => (current ? { ...current, answerError: payload.error } : current));
|
setSearch((current) => (current ? { ...current, answerError: payload.error } : current));
|
||||||
},
|
},
|
||||||
onDone: (payload) => {
|
onDone: (payload) => {
|
||||||
@@ -172,6 +184,7 @@ export default function SearchRoutePage() {
|
|||||||
},
|
},
|
||||||
onError: (payload) => {
|
onError: (payload) => {
|
||||||
if (requestId !== requestCounterRef.current) return;
|
if (requestId !== requestCounterRef.current) return;
|
||||||
|
if (isInterruptedStreamError(payload.message)) return;
|
||||||
setError(payload.message);
|
setError(payload.message);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -180,6 +193,7 @@ export default function SearchRoutePage() {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (abortController.signal.aborted) return;
|
if (abortController.signal.aborted) return;
|
||||||
const message = err instanceof Error ? err.message : String(err);
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
|
if (isInterruptedStreamError(message)) 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user