Skip to content

Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.

fix(studio): prevent stuck reference uploads

antilya3e7c1ce82994
diff --git a/packages/studio/src/muapi.js b/packages/studio/src/muapi.js
index 1bef9fec..036c7d2f 100644
--- a/packages/studio/src/muapi.js
+++ b/packages/studio/src/muapi.js
@@ -7,6 +7,8 @@ const BASE_URL = (typeof window !== 'undefined' && window.location?.protocol?.st
? '/api'
: 'https://api.muapi.ai';
const PROXY_WF_BASE = '/api/workflow';
+const FILE_UPLOAD_TIMEOUT_MS = 300_000;
+const FILE_UPLOAD_PENDING_PROGRESS = 99;
function notifyAuthRequired(status, detail) {
if (typeof window === 'undefined') return;
@@ -254,11 +256,15 @@ export function uploadFile(apiKey, file, onProgress) {
const xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.setRequestHeader('x-api-key', apiKey);
+ xhr.timeout = FILE_UPLOAD_TIMEOUT_MS;
if (onProgress) {
xhr.upload.onprogress = (event) => {
if (event.lengthComputable) {
- const percentComplete = Math.round((event.loaded / event.total) * 100);
+ const percentComplete = Math.min(
+ Math.round((event.loaded / event.total) * 100),
+ FILE_UPLOAD_PENDING_PROGRESS
+ );
onProgress(percentComplete);
}
};
@@ -272,6 +278,7 @@ export function uploadFile(apiKey, file, onProgress) {
if (!fileUrl) {
reject(new Error('No URL returned from file upload'));
} else {
+ onProgress?.(100);
resolve(fileUrl);
}
} catch (e) {
@@ -291,6 +298,7 @@ export function uploadFile(apiKey, file, onProgress) {
};
xhr.onerror = () => reject(new Error('Network error during file upload'));
+ xhr.ontimeout = () => reject(new Error('File upload timed out. Please try again.'));
xhr.send(formData);
});
}