block/buzz · info · Error

upload cancelled

Error message

upload cancelled

What it means

uploadMediaFile checks the AbortSignal at two points before doing work (before reading the file into bytes and before dispatching the IPC upload). If signal.aborted is already true, it throws 'upload cancelled' so no bytes are read or sent. It is an explicit cancellation path, not a failure of the upload itself.

Source

Thrown at desktop/src/shared/api/tauriMedia.ts:31

}

/** Transfer a browser File to Rust as a raw IPC body, avoiding JSON expansion. */
export async function uploadMediaFile(
  file: File,
  progressId?: string,
  signal?: AbortSignal,
  onDispatch?: () => void,
): Promise<BlobDescriptor> {
  const headers: Record<string, string> = {
    "x-buzz-filename": encodeRawIpcHeader(file.name),
  };
  if (progressId) {
    headers["x-buzz-progress-id"] = encodeRawIpcHeader(progressId);
  }

  if (signal?.aborted) throw new Error("upload cancelled");
  const bytes = new Uint8Array(await file.arrayBuffer());
  if (signal?.aborted) throw new Error("upload cancelled");
  onDispatch?.();
  try {
    return await invokeTauriRaw<BlobDescriptor>(
      "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()

View on GitHub (pinned to dad5a33865)

Solutions

  1. This is expected behavior on cancel — catch it and treat the upload as cancelled, not failed.
  2. Don't abort the controller until you truly want to cancel; use a separate signal per upload.
  3. If you never want cancellation, pass undefined for signal.
  4. Only show an error toast when the error is not the cancellation message.

Example fix

// before
try { await uploadMediaFile(file, { signal }); } catch (e) { showError(e); }
// after
try { await uploadMediaFile(file, { signal }); }
catch (e) { if (!isUploadCancelled(e)) showError(e); }
Defensive patterns

Strategy: try-catch

Validate before calling

if (signal?.aborted) return; // skip upload entirely, no error path needed

Type guard

function isUploadCancelled(e: unknown): boolean { return e instanceof Error && e.message === 'upload cancelled'; }

Try / catch

try { await uploadMediaFile(file, { signal }); } catch (e) { if (isUploadCancelled(e)) return; throw e; }

Prevention

When it happens

Trigger: Caller passes an AbortSignal that was aborted before calling uploadMediaFile, or aborts between the two checks (e.g. user cancels while file.arrayBuffer() is reading).

Common situations: User hits Cancel in the upload UI immediately; component unmount aborts the controller; a competing action (delete attachment) aborts the in-flight upload.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05). Data as JSON: /api/errors/82e02362c2c5c0e4. Report an issue: GitHub.