Skip to content

Commit 9ed7efc

Browse files
authored
Increase the size of child_process buffers (#1506)
When running `execSwift` or `execFile` it was possible for very large results to exceed the default max buffer size as defined by Node.JS (1MB). This was happening when initializing a complex package during the `swift package show-dependencies --format json` call, which produced a very large dependency graph.
1 parent fd1c075 commit 9ed7efc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/utilities/utilities.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export async function execFile(
109109
options.env = { ...(options.env ?? process.env), ...runtimeEnv };
110110
}
111111
}
112+
options = {
113+
...options,
114+
maxBuffer: options.maxBuffer ?? 1024 * 1024 * 64, // 64MB
115+
};
112116
return new Promise<{ stdout: string; stderr: string }>((resolve, reject) => {
113117
cp.execFile(executable, args, options, (error, stdout, stderr) => {
114118
if (error) {
@@ -198,6 +202,10 @@ export async function execSwift(
198202
...configuration.swiftEnvironmentVariables,
199203
};
200204
}
205+
options = {
206+
...options,
207+
maxBuffer: options.maxBuffer ?? 1024 * 1024 * 64, // 64MB
208+
};
201209
return await execFile(swift, args, options, folderContext);
202210
}
203211

0 commit comments

Comments
 (0)