Add AbortController cleanup to async frontend effects

This commit is contained in:
2026-04-18 21:30:57 +02:00
parent 2105f8b435
commit 6c053cdaee
16 changed files with 128 additions and 37 deletions

View File

@@ -106,12 +106,14 @@ export function ActivateJailDialog({
useEffect(() => {
if (!open || !jail) return;
const controller = new AbortController();
setValidating(true);
setValidationIssues([]);
setValidationWarnings([]);
onValidate()
.then((result) => {
if (controller.signal.aborted) return;
setValidationIssues(result.issues);
})
.catch(() => {
@@ -119,8 +121,13 @@ export function ActivateJailDialog({
// attempt activation and let the server decide.
})
.finally(() => {
if (controller.signal.aborted) return;
setValidating(false);
});
return (): void => {
controller.abort();
};
}, [open, jail, onValidate]);
const handleClose = (): void => {