MCPcopy Create free account
hub / github.com/vercel/vercel / processLambdaOutput

Function processLambdaOutput

packages/cli/src/util/dev/builder-worker.cjs:65–86  ·  view source on GitHub ↗
(output)

Source from the content-addressed store, hash-verified

63
64 // Helper to handle zipBuffer - writes to temp file if too large for IPC
65 async function processLambdaOutput(output) {
66 const zipBuffer = await output.createZip();
67 // Delete files after creating zip to avoid OOM when serializing via IPC.
68 // The zipBuffer contains all file data, so files is no longer needed.
69 delete output.files;
70
71 // For large zip buffers, write to a temp file instead of sending via IPC.
72 // JSON serialization of large Buffers causes OOM because each byte becomes
73 // a separate array element (e.g., {"type":"Buffer","data":[1,2,3,...]}).
74 if (zipBuffer.length > ZIP_BUFFER_FILE_THRESHOLD) {
75 const tempDir = os.tmpdir();
76 const randomId = crypto.randomBytes(8).toString('hex');
77 const zipFilePath = path.join(
78 tempDir,
79 `vercel-dev-lambda-${randomId}.zip`
80 );
81 fs.writeFileSync(zipFilePath, zipBuffer);
82 output.zipBufferPath = zipFilePath;
83 } else {
84 output.zipBuffer = zipBuffer;
85 }
86 }
87
88 // Container Lambdas carry an OCI image reference in `handler`, not a code
89 // bundle, so there is nothing to zip. They are built and run locally by the

Callers 1

processMessageFunction · 0.85

Calls 4

createZipMethod · 0.80
toStringMethod · 0.45
joinMethod · 0.45
writeFileSyncMethod · 0.45

Tested by

no test coverage detected