{"record":{"id":"7c0a23678e628581","repo":"sveltejs/kit","slug":"incomplete-file-data","errorCode":null,"errorMessage":"incomplete file data","messagePattern":"incomplete file data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/form-utils.js","lineNumber":462,"sourceCode":"\t\t\tsize,\n\t\t\tthis.lastModified,\n\t\t\tthis.#get_chunk,\n\t\t\tthis.#offset + start\n\t\t);\n\n\t\treturn file;\n\t}\n\tstream() {\n\t\tconst range = read_range(this.#get_chunk, this.#offset, this.size);\n\t\tconst size = this.size;\n\t\treturn stream_from_iterable(\n\t\t\t(async function* () {\n\t\t\t\tlet cursor = 0;\n\t\t\t\tfor await (const chunk of range) {\n\t\t\t\t\tcursor += chunk.byteLength;\n\t\t\t\t\tyield chunk;\n\t\t\t\t}\n\t\t\t\tif (cursor < size) throw new Error('incomplete file data');\n\t\t\t})()\n\t\t);\n\t}\n\tasync text() {\n\t\treturn text_decoder.decode(await this.arrayBuffer());\n\t}\n}\n\nconst path_regex = /^[a-zA-Z_$]\\w*(\\.[a-zA-Z_$]\\w*|\\[\\d+\\])*$/;\n\n/**\n * @param {string} path\n */\nexport function split_path(path) {\n\tif (!path_regex.test(path)) {\n\t\tthrow new Error(\n\t\t\t`Invalid field name ${path}` +\n\t\t\t\t(DEV","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/form-utils.js#L444-L480","documentation":"When reading a large uploaded file from a range/response stream, the File streamer yields chunks and asserts the total bytes received equals the declared file size. If the stream ends before size bytes arrive (truncated upload or dropped connection), it throws 'incomplete file data'.","triggerScenarios":"A client aborts or drops the network connection mid-upload of a large file; server-side truncation; storage/range source returning fewer bytes than the advertised size.","commonSituations":"Flaky mobile connections during large binary form uploads; proxies or CDNs cutting long-running uploads; misbehaving custom range/storage backends reporting a larger size than they serve.","solutions":["Retry the upload from the client, ideally with resumable/chunked upload support.","Verify the client sent the complete body (check Content-Length vs received bytes) and that no proxy terminated the stream.","If using a custom range source, ensure it yields exactly `size` bytes."],"exampleFix":"// before\nconst data = await file.arrayBuffer(); // throws on truncated stream\n// after\ntry {\n  const data = await file.arrayBuffer();\n} catch (e) {\n  if (e.message === 'incomplete file data') return fail(400, { error: 'Upload truncated, please retry' });\n  throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const buf = await file.arrayBuffer();\n} catch (e) {\n  if (e.message === 'incomplete file data') {\n    // prompt client to re-upload / resume\n  } else throw e;\n}","preventionTips":["Upload large files over stable connections and support client-side retry/resume.","Check proxies/CDN timeouts for long uploads.","Ensure custom range sources yield exactly the advertised byte count."],"tags":["files","upload","stream-truncation","network"],"backgroundTag":"incomplete-file-data","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}