fix: wrap SSE state updates in flushSync to resolve React error #418
This commit is contained in:
1 parent
cf89681576
commit
40a21ba767
1 file changed
+3
@@ -10,6 +10,7 @@ import {
|
||||
SearchX,
|
||||
} from "lucide-react";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { flushSync } from "react-dom";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { adminFetch } from "@/lib/admin-fetch";
|
||||
@@ -246,6 +247,7 @@ export function AuditClient() {
|
||||
try {
|
||||
const evt = JSON.parse(part.slice(6)) as AuditEvent;
|
||||
|
||||
flushSync(() => {
|
||||
if (evt.type === "progress") {
|
||||
setProgress(evt.message ?? "");
|
||||
}
|
||||
@@ -320,6 +322,7 @@ export function AuditClient() {
|
||||
setProgress(`ERROR: ${evt.message ?? ""}`);
|
||||
toast.error(evt.message ?? "Audit failed");
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
// skip parse errors
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user