block/buzz · error · Error
Media upload failed.
Error message
Media upload failed.
What it means
Fallback branch of uploadMediaFile's error normalization: when the IPC rejection is neither an Error, a non-empty string, nor an object with a usable `message`, it throws the generic 'Media upload failed.' The real cause is unknowable from the thrown value alone.
Source
Thrown at desktop/src/shared/api/tauriMedia.ts:53
"upload_media_bytes_raw",
bytes,
{
headers,
},
);
} catch (error) {
if (error instanceof Error) throw error;
if (typeof error === "string" && error.trim()) throw new Error(error);
if (
typeof error === "object" &&
error !== null &&
"message" in error &&
typeof error.message === "string" &&
error.message.trim()
) {
throw new Error(error.message);
}
throw new Error("Media upload failed.");
}
}
/** Stop the native HTTP request associated with a background media upload. */
export async function cancelMediaUpload(progressId: string): Promise<void> {
await invokeTauri("cancel_media_upload", { progressId });
}
/** Release the renderer's cancellation ownership after an upload settles. */
export async function releaseMediaUpload(progressId: string): Promise<void> {
await invokeTauri("release_media_upload", { progressId });
}
/**
* Open a native single-file picker constrained to images and upload the
* chosen file. Non-image files are rejected in Rust (via MIME sniffing)
* before the bytes leave the client, so discarded/non-image selections never
* reach the relay. Resolves to `null` when the user cancels the dialog.View on GitHub (pinned to dad5a33865)
Solutions
- Check the native/Tauri logs (devtools console, system log) for the underlying failure around the upload time.
- Verify network connectivity and media server reachability from the device.
- Confirm the Tauri media plugin/command versions match the frontend invoke signature.
- Wrap invokeTauriRaw calls to log the raw rejection before normalization so future failures aren't opaque.
Example fix
// before
} catch (error) {
throw new Error("Media upload failed.");
}
// after
} catch (error) {
console.error("upload_media_bytes_raw rejection:", error);
throw new Error(`Media upload failed: ${JSON.stringify(error)}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!navigator.onLine) throw new Error('Offline: upload deferred');
Type guard
function isGenericUploadFailure(e: unknown): boolean { return e instanceof Error && e.message === 'Media upload failed.'; }
Try / catch
try { await uploadMediaFile(file); } catch (e) { if (isGenericUploadFailure(e)) showRetryDialog(file); else throw e; }
Prevention
- Log raw IPC rejections before normalization for diagnosability
- Check native/Tauri logs when the message is generic
- Verify network reachability before upload and offer retry
When it happens
Trigger: upload_media_bytes_raw rejects with an empty string, null/undefined, a number, or an object without a message field — the native layer failed without a descriptive payload.
Common situations: Native HTTP stack crashing without text; unexpected plugin response shape; device offline with a terse rejection; progress IPC channel torn down mid-upload.
Related errors
- ${error}
- ${error.message}
- {error} (and the local stores could not be restored: {restor
- upload cancelled
- Media fetch cancelled
AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05).
Data as JSON: /api/errors/73040d0f8c9860ba.
Report an issue: GitHub.