{"record":{"id":"63d26e62079820d3","repo":"transloadit/uppy","slug":"failed-to-download-file","errorCode":null,"errorMessage":"Failed to download file","messagePattern":"Failed to download file","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"packages/@uppy/companion/src/server/controllers/get.ts","lineNumber":35,"sourceCode":"  }\n\n  const getSize = async () =>\n    provider.size({ id, providerUserSession, query: req.query })\n\n  const download = () =>\n    provider.download({\n      id,\n      providerUserSession,\n      query: req.query,\n      companion: req.companion,\n    })\n\n  try {\n    await startDownUpload({ req, res, getSize, download })\n  } catch (err) {\n    logger.error(err, 'controller.get.error', req.id)\n    if (respondWithError(err, res)) return\n    res.status(500).json({ message: 'Failed to download file' })\n  }\n}\n","sourceCodeStart":17,"sourceCodeEnd":38,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/companion/src/server/controllers/get.ts#L17-L38","documentation":"This is Companion's GET download controller catching any error from startDownUpload (the pipeline that streams a provider file to the client or an uploader). When the failure isn't mapped by respondWithError, Companion responds 500 with 'Failed to download file'.","triggerScenarios":"GET /companion/:provider/get/:id where the provider download fails unexpectedly: expired access token mid-download, provider 5xx, socket abort, or an error shape not covered by respondWithError's mapping.","commonSituations":"Long downloads where the provider OAuth token expires, transient provider outages, network interruption between Companion and the provider, or bugs in custom provider implementations returning non-standard errors.","solutions":["Check Companion logs (logger.error output with req.id) for the underlying cause","Retry the download — many causes are transient provider/network failures","If token expiry recurs, reduce download window or refresh provider tokens more aggressively"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"const res = await fetch(url)\nif (res.status === 500 && (await res.json()).message === 'Failed to download file') {\n  await new Promise((r) => setTimeout(r, 1000))\n  return retryFetch(url, retries - 1)\n}","preventionTips":["Correlate failures with req.id in Companion logs to find root cause","Implement client-side retry with backoff for downloads","Monitor provider token expiry and provider status pages"],"tags":["companion","server","download","provider","http-500"],"backgroundTag":"provider-download-failed","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}