{"record":{"id":"8a6f65e95b7decf6","repo":"microsoft/playwright","slug":"cannot-transfer-files-larger-than-50mb-to-a-browse","errorCode":null,"errorMessage":"Cannot transfer files larger than 50Mb to a browser not co-located with the server","messagePattern":"Cannot transfer files larger than 50Mb to a browser not co-located with the server","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/fileUploadUtils.ts","lineNumber":66,"sourceCode":"    localDirectory = (directoryStream as WritableStreamDispatcher).path();\n\n  if (localPaths) {\n    for (const p of localPaths)\n      assert(path.isAbsolute(p) && path.resolve(p) === p, 'Paths provided to localPaths must be absolute and fully resolved.');\n  }\n\n  let fileBuffers: {\n    name: string,\n    mimeType?: string,\n    buffer: Buffer,\n    lastModifiedMs?: number,\n  }[] | undefined = payloads;\n\n  if (!frame._page.browserContext._browser._isBrowserCollocatedWithServer) {\n    // If the browser is on a different machine read files into buffers.\n    if (localPaths) {\n      if (await filesExceedUploadLimit(localPaths))\n        throw new Error('Cannot transfer files larger than 50Mb to a browser not co-located with the server');\n      fileBuffers = await Promise.all(localPaths.map(async item => {\n        return {\n          name: path.basename(item),\n          buffer: await fs.promises.readFile(item),\n          lastModifiedMs: (await fs.promises.stat(item)).mtimeMs,\n        };\n      }));\n      localPaths = undefined;\n    }\n  }\n\n  const filePayloads: types.FilePayload[] | undefined = fileBuffers?.map(payload => ({\n    name: payload.name,\n    mimeType: payload.mimeType || mime.getType(payload.name) || 'application/octet-stream',\n    buffer: payload.buffer.toString('base64'),\n    lastModifiedMs: payload.lastModifiedMs\n  }));\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/fileUploadUtils.ts#L48-L84","documentation":"When the browser is not collocated with the Playwright server and localPaths are used, files are read into memory buffers to ship across the boundary. If their combined size meets or exceeds 50 MiB (fileUploadSizeLimit) the upload is refused to avoid exhausting memory.","triggerScenarios":"Calling setInputFiles(paths) where the total size of all listed files is >= 50 MiB, while _isBrowserCollocatedWithServer is false (remote browser / separate browser server host). filesExceedUploadLimit sums fs.stat sizes.","commonSituations":"Uploading large media, PDFs, archives, or datasets in CI against a remote browser service; batch uploads of many files whose total crosses 50 MiB; test fixtures with oversized attachments.","solutions":["Switch to streaming uploads via a writable stream when available to avoid the in-memory cap.","Reduce the per-call payload below 50 MiB (split into multiple calls or trim fixtures).","Run the browser collocated with the server so the 50 MiB transfer limit does not apply.","Compress or sample the test data so the fixture stays under the limit."],"exampleFix":"// before: 60 MiB file against remote browser -> throws\nawait handle.setInputFiles('/data/big.mov');\n// after: stream instead, or shrink fixture\nawait handle.setInputFiles('/data/small.mov');","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst LIMIT = 50 * 1024 * 1024;\nasync function totalSize(paths: string[]) {\n  return (await Promise.all(paths.map(p => fs.promises.stat(p).then(s => s.size)))).reduce((a,b)=>a+b,0);\n}\nif (await totalSize(paths) >= LIMIT) throw new Error('over 50MiB');","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Keep test upload fixtures small (<50 MiB) when targeting a remote browser.","Use streaming for legitimately large files."],"tags":["file-upload","size-limit","remote"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}