{"record":{"id":"45a7015be8875eb2","repo":"unslothai/unsloth","slug":"label-did-not-report-completion-the-connection","errorCode":null,"errorMessage":"${label} did not report completion: the connection closed before the server's reply arrived. Check the model's status before retrying.","messagePattern":"(.+?) did not report completion: the connection closed before the server's reply arrived\\. Check the model's status before retrying\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"studio/frontend/src/features/chat/api/padded-response.ts","lineNumber":22,"sourceCode":"/**\n * `/api/inference/load` and `/unload` pad their body so a proxy cannot time the request\n * out, committing the 200 before the work finishes (`_tunnel_safe_json` in\n * studio/backend/routes/inference.py). A proxy giving up mid-pad leaves a 200 with an\n * empty or truncated body; accepting that reports an unfinished load as done. Only\n * these two routes commit that early, so only they require a payload; elsewhere an\n * empty body is by design. Mirrored by `require_completed_padded_body` in\n * unsloth_cli/_inference.py.\n */\nexport function assertCompletedPaddedBody(body: unknown, label: string): void {\n  const complete =\n    typeof body === \"object\" &&\n    body !== null &&\n    !Array.isArray(body) &&\n    Object.keys(body).length > 0;\n  if (complete) {\n    return;\n  }\n  throw new Error(\n    `${label} did not report completion: the connection closed before the server's reply arrived. Check the model's status before retrying.`,\n  );\n}\n","sourceCodeStart":4,"sourceCodeEnd":26,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/frontend/src/features/chat/api/padded-response.ts#L4-L26","documentation":"assertCompletedPaddedBody validates that a padded (non-streaming) response body is a non-empty, non-array object — the protocol's completion marker. An empty object, null, array, primitive, or empty body means the connection closed before the server's reply arrived, mirroring the backend check require_completed_padded_body in unsloth_cli/_inference.py. The label names which operation failed.","triggerScenarios":"Calling a padded/non-stream endpoint whose proxy or server returns an empty body (200 with no content, or truncated JSON parsed to null) — e.g. model server crashed after accepting the request, or a gateway timed out and returned an empty 200.","commonSituations":"Model server OOM/restart mid-inference; reverse proxy buffering and truncating long responses; connection killed after headers but before body; backend version drift where the padding protocol changed.","solutions":["Check the model server's status/logs — the message explicitly says the reply never arrived, so the server side is the suspect.","Look for proxy response-size/time limits truncating the body.","Retry the request once the model is healthy (the error is safe to retry — no side effects).","If it persists, verify the frontend and backend padding-protocol versions match (require_completed_padded_body mirror)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import { assertCompletedPaddedBody } from './padded-response';\n// Pre-flight the model is accepting requests before a long padded call\nif (!(await modelHealthcheck())) throw new Error('Model not ready');","typeGuard":"function isPaddedBodyIncomplete(e: unknown): boolean {\n  return e instanceof Error && e.message.includes('did not report completion');\n}","tryCatchPattern":"try { assertCompletedPaddedBody(body, label); }\ncatch (e) {\n  if (isPaddedBodyIncomplete(e) && attempt < 2) { await backoff(attempt); return requestAgain(); }\n  throw e;\n}","preventionTips":["Padded calls are side-effect free — make them idempotent and restartable.","Monitor model-server health and route around unhealthy instances.","Keep the frontend assert in lockstep with require_completed_padded_body on version bumps."],"tags":["validation","protocol","model-server","truncated-response"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}