Compare commits

...

4 Commits

Author SHA1 Message Date
Johnpaul
dda9cf68f2 Merge remote-tracking branch 'origin/main' into fix/coderabbit-issue-9226 2026-04-06 18:22:04 +01:00
Johnpaul
e93476174f fix: use AbortSignal.timeout for upload timeout
Replace manual AbortController+setTimeout with AbortSignal.timeout(),
fixing unreachable clearTimeout on error path and distinguishing
TimeoutError from AbortError for future cancel support.
2026-04-06 18:17:00 +01:00
Johnpaul Chiwetelu
fb559ac5ac Merge branch 'main' into fix/coderabbit-issue-9226 2026-03-10 02:21:27 +01:00
CodeRabbit Fixer
c971cb5646 fix: Add timeout and abort mechanism for image upload (#9226)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 17:49:33 +01:00
2 changed files with 9 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import { api } from '@/scripts/api'
import { useAssetsStore } from '@/stores/assetsStore'
const PASTED_IMAGE_EXPIRY_MS = 2000
const UPLOAD_TIMEOUT_MS = 120_000
interface ImageUploadFormFields {
/**
@@ -30,7 +31,8 @@ const uploadFile = async (
const resp = await api.fetchApi('/upload/image', {
method: 'POST',
body
body,
signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS)
})
if (resp.status !== 200) {
@@ -88,7 +90,11 @@ export const useNodeImageUpload = (
if (!path) return
return path
} catch (error) {
useToastStore().addAlert(String(error))
if (error instanceof DOMException && error.name === 'TimeoutError') {
useToastStore().addAlert(t('g.uploadTimedOut'))
} else {
useToastStore().addAlert(String(error))
}
}
}

View File

@@ -199,6 +199,7 @@
"control_before_generate": "control before generate",
"choose_file_to_upload": "choose file to upload",
"uploadAlreadyInProgress": "Upload already in progress",
"uploadTimedOut": "Upload timed out. Please try again.",
"capture": "capture",
"nodes": "Nodes",
"nodesCount": "{count} node | {count} nodes",