{"record":{"id":"5a4906b1a1188558","repo":"alyssaxuu/screenity","slug":"drive-resumable-init-missing-location-header","errorCode":null,"errorMessage":"Drive resumable init missing Location header","messagePattern":"Drive resumable init missing Location header","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/drive/handleSaveToDrive.js","lineNumber":155,"sourceCode":"        Authorization: `Bearer ${token}`,\n        \"Content-Type\": \"application/json; charset=UTF-8\",\n        \"X-Upload-Content-Type\": blob.type || \"application/octet-stream\",\n        \"X-Upload-Content-Length\": String(blob.size),\n      },\n      body: JSON.stringify(metadata),\n    }\n  );\n\n  if (!initRes.ok) {\n    const errBody = await initRes.text().catch(() => \"\");\n    throw new Error(\n      `Drive resumable init failed: ${initRes.status} ${errBody}`\n    );\n  }\n\n  const uploadUrl = initRes.headers.get(\"location\");\n  if (!uploadUrl) {\n    throw new Error(\"Drive resumable init missing Location header\");\n  }\n\n  const totalSize = blob.size;\n  let offset = 0;\n  let stalledRounds = 0;\n\n  // 308 = more to send (Range header has last byte received), 200/201 = done\n  while (offset < totalSize) {\n    const end = Math.min(offset + CHUNK_SIZE, totalSize);\n    const chunkBlob = blob.slice(offset, end);\n    const buffer = await chunkBlob.arrayBuffer();\n    const contentRange = `bytes ${offset}-${end - 1}/${totalSize}`;\n\n    let chunkRes = null;\n    let advanced = false;\n    let stalled = false;\n    for (let attempt = 0; attempt < MAX_CHUNK_ATTEMPTS; attempt++) {\n      try {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/drive/handleSaveToDrive.js#L137-L173","documentation":"The resumable init request returned success (2xx) but carried no Location header, so there is no upload session URL to PUT chunks to. A guard thrown in uploadResumable; without uploadUrl the resumable protocol cannot proceed.","triggerScenarios":"Thrown at src/pages/Background/drive/handleSaveToDrive.js:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the init request once — a missing Location on 2xx is usually transient or a proxy stripping headers","Check for service workers/intermediaries dropping response headers","Fall back to a simple multipart upload if Location is repeatedly absent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}