{"record":{"id":"9c880e8f4332d0a5","repo":"garrytan/gstack","slug":"disk-write-failed-writeerr-message","errorCode":null,"errorMessage":"Disk write failed: ${writeErr.message}","messagePattern":"Disk write failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":1386,"sourceCode":"      const lines: string[] = [];\n      for (let i = 0; i < toDownload.length; i++) {\n        const { url, type } = toDownload[i];\n        try {\n          // Same gate as the download command — page.request.fetch\n          // must not reach cloud metadata, ULA ranges, or the rest of\n          // the blocklist. See url-validation.ts for the full list.\n          await validateNavigationUrl(url);\n          const response = await page.request.fetch(url, { timeout: 30000 });\n          if (response.status() >= 400) throw new Error(`HTTP ${response.status()}`);\n          const ct = response.headers()['content-type'] || 'application/octet-stream';\n          const ext = mimeToExt(ct.split(';')[0].trim());\n          const filename = `${type}-${String(i + 1).padStart(3, '0')}${ext}`;\n          const filePath = path.join(dir, filename);\n          const body = Buffer.from(await response.body());\n          try {\n            fs.writeFileSync(filePath, body);\n          } catch (writeErr: any) {\n            throw new Error(`Disk write failed: ${writeErr.message}`);\n          }\n          manifest.files.push({ path: filename, src: url, size: body.length, type: ct.split(';')[0].trim() });\n          manifest.total_size += body.length;\n          manifest.succeeded++;\n          lines.push(`  [${i + 1}/${toDownload.length}] ${filename} (${Math.round(body.length / 1024)}KB)`);\n        } catch (err: any) {\n          manifest.files.push({ path: null, src: url, size: 0, type: '', error: err.message });\n          manifest.failed++;\n          lines.push(`  [${i + 1}/${toDownload.length}] FAILED: ${err.message}`);\n        }\n        // 100ms delay between downloads\n        if (i < toDownload.length - 1) await new Promise(r => setTimeout(r, 100));\n      }\n\n      // Write manifest\n      fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifest, null, 2));\n\n      return `Scraped ${toDownload.length} items to ${dir}/\\n${lines.join('\\n')}\\n\\nSummary: ${manifest.succeeded} succeeded, ${manifest.failed} failed, ${Math.round(manifest.total_size / 1024)}KB total`;","sourceCodeStart":1368,"sourceCodeEnd":1404,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L1368-L1404","documentation":"Error \"Disk write failed: ${writeErr.message}\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:1386 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}