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

Function deserializeOutput

packages/cli/src/util/dev/builder.ts:95–131  ·  view source on GitHub ↗

* Deserialize a single output object from its IPC-serialized form. * Converts JSON-ified Buffers back to real Buffers and reads temp files for large zipBuffers.

(
  obj: SerializedOutput
)

Source from the content-addressed store, hash-verified

93 * Converts JSON-ified Buffers back to real Buffers and reads temp files for large zipBuffers.
94 */
95async function deserializeOutput(
96 obj: SerializedOutput
97): Promise<BuilderOutput> {
98 switch (obj.type) {
99 case 'FileFsRef': {
100 return Object.assign(Object.create(FileFsRef.prototype), obj);
101 }
102 case 'FileBlob': {
103 const fileBlob: FileBlob = Object.assign(
104 Object.create(FileBlob.prototype),
105 obj
106 );
107 fileBlob.data = Buffer.from(obj.data.data);
108 return fileBlob;
109 }
110 case 'Lambda': {
111 const lambda: BuiltLambda = Object.assign(
112 Object.create(Lambda.prototype),
113 obj
114 );
115 // Convert the JSON-ified Buffer object back into an actual Buffer,
116 // or read from temp file if it was too large for IPC
117 if (obj.zipBufferPath) {
118 lambda.zipBuffer = readFileSync(obj.zipBufferPath);
119 // Clean up the temp file after reading
120 try {
121 unlinkSync(obj.zipBufferPath);
122 } catch {
123 // Ignore cleanup errors
124 }
125 } else if (obj.zipBuffer) {
126 lambda.zipBuffer = Buffer.from(obj.zipBuffer.data);
127 }
128 return lambda;
129 }
130 }
131}
132
133/**
134 * Deserialize all build outputs from their IPC-serialized form.

Callers 1

deserializeBuildOutputsFunction · 0.85

Calls 1

createMethod · 0.45

Tested by

no test coverage detected