alyssaxuu/screenity · error · Error

Drive resumable init failed: ${initRes.status} ${errBody}

Error message

Drive resumable init failed: ${initRes.status} ${errBody}

What it means

The resumable upload session initialization POST to the Drive upload endpoint returned a non-OK status. Thrown in uploadResumable before any bytes are sent; causes include an invalid/expired token, bad metadata (invalid parent folderId or filename), or X-Upload-Content-Length/type inconsistent with the blob.

Source

Thrown at src/pages/Background/drive/handleSaveToDrive.js:148

  const metadata = { name: sanitizeDriveName(fileName), parents: [folderId] };

  const initRes = await fetch(
    `https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable`,
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${token}`,
        "Content-Type": "application/json; charset=UTF-8",
        "X-Upload-Content-Type": blob.type || "application/octet-stream",
        "X-Upload-Content-Length": String(blob.size),
      },
      body: JSON.stringify(metadata),
    }
  );

  if (!initRes.ok) {
    const errBody = await initRes.text().catch(() => "");
    throw new Error(
      `Drive resumable init failed: ${initRes.status} ${errBody}`
    );
  }

  const uploadUrl = initRes.headers.get("location");
  if (!uploadUrl) {
    throw new Error("Drive resumable init missing Location header");
  }

  const totalSize = blob.size;
  let offset = 0;
  let stalledRounds = 0;

  // 308 = more to send (Range header has last byte received), 200/201 = done
  while (offset < totalSize) {
    const end = Math.min(offset + CHUNK_SIZE, totalSize);
    const chunkBlob = blob.slice(offset, end);
    const buffer = await chunkBlob.arrayBuffer();

View on GitHub (pinned to 512606387b)

Solutions

  1. Read the status and errBody for the Drive error reason
  2. Refresh the OAuth token on 401/403 and retry the upload
  3. Validate metadata: folderId exists, fileName sanitized and non-empty
  4. Retry with backoff on 429/5xx; fail fast on 4xx client errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/pages/Background/drive/handleSaveToDrive.js:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of alyssaxuu/screenity@512606387b (2026-09-02). Data as JSON: /api/errors/1bf65e9c5c1655a3. Report an issue: GitHub.