fix(frontend): preserve cancellation and reject invalid query data (#6143)

* fix(frontend): preserve request cancellation and schema failures

* fix(frontend): limit schema failures to query boundaries

* fix(frontend): keep invalid settings recoverable

Keep settings payload validation tolerant so values accepted by the backend remain editable, while paged clients still fail closed. Add an AbortSignal.any fallback and make timeout tests event-driven.

---------

Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
This commit is contained in:
PathGaoandPathGao authored and GitHub committed 2026-07-29 20:51:40 +02:00 Unverified
1 parent c3fa73d5a0
commit 863473783d
6 files changed
+183 -3

No files matched your search

+6
View File
@@ -1,10 +1,15 @@
import type { z } from 'zod';
import { Msg } from '@/utils';
interface ParseMsgOptions {
strict?: boolean;
}
export function parseMsg<T extends z.ZodType>(
msg: Msg<unknown>,
schema: T,
context: string,
options: ParseMsgOptions = {},
): Msg<z.infer<T>> {
if (!msg.success || msg.obj == null) {
return msg as Msg<z.infer<T>>;
@@ -12,6 +17,7 @@ export function parseMsg<T extends z.ZodType>(
const result = schema.safeParse(msg.obj);
if (!result.success) {
console.warn(`[zod] ${context} response failed validation`, result.error.issues);
if (options.strict) throw new Error(`${context} response failed validation`);
return msg as Msg<z.infer<T>>;
}
return new Msg<z.infer<T>>(msg.success, msg.msg, result.data);