{"record":{"id":"eac18455852e964f","repo":"alyssaxuu/screenity","slug":"drive-chunk-put-failed-chunkres-status-errbo","errorCode":null,"errorMessage":"Drive chunk PUT failed: ${chunkRes.status} ${errBody}","messagePattern":"Drive chunk PUT failed: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/drive/handleSaveToDrive.js","lineNumber":229,"sourceCode":"        const range = chunkRes.headers.get(\"range\");\n        const match = range && range.match(/bytes=0-(\\d+)/);\n        const nextOffset = match ? parseInt(match[1], 10) + 1 : offset;\n        if (nextOffset > offset) {\n          offset = nextOffset;\n          advanced = true;\n        } else {\n          stalled = true;\n        }\n        break;\n      }\n\n      const isTransient =\n        chunkRes.status === 408 ||\n        chunkRes.status === 429 ||\n        chunkRes.status >= 500;\n      if (!isTransient || attempt === MAX_CHUNK_ATTEMPTS - 1) {\n        const errBody = await chunkRes.text().catch(() => \"\");\n        throw new Error(\n          `Drive chunk PUT failed: ${chunkRes.status} ${errBody}`\n        );\n      }\n      const delay = Math.min(1000 * Math.pow(2, attempt), 30000);\n      const jitter = Math.random() * 250;\n      diagEvent(\"drive-chunk-retry\", {\n        offset,\n        status: chunkRes.status,\n        attempt: attempt + 1,\n        delayMs: Math.round(delay + jitter),\n      });\n      await new Promise((r) => setTimeout(r, delay + jitter));\n    }\n\n    if (advanced) {\n      stalledRounds = 0;\n      continue;\n    }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/drive/handleSaveToDrive.js#L211-L247","documentation":"A chunk PUT to the resumable session URL failed with a non-transient status (not 408/429/5xx) or the final retry attempt failed, so the chunk cannot be committed. Thrown in uploadResumable after reading errBody when isTransient is false or attempts are exhausted.","triggerScenarios":"Thrown at src/pages/Background/drive/handleSaveToDrive.js:229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read errBody/status: 404/410 means the session expired — restart the upload from scratch","For 408/429/5xx rely on the existing exponential backoff with jitter loop","Query session state via PUT Content-Range: bytes */total to find the last committed byte","Report the offset so a restarted upload can resume"],"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"}