Fix: Add maxBuffer option to execAsync functions to handle large backup restores

Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-28 19:30:43 +00:00
parent 19b3dde034
commit 34d86030e7

View File

@@ -14,7 +14,12 @@ export const execAsync = async (
options?: { cwd?: string; env?: NodeJS.ProcessEnv; shell?: string },
): Promise<{ stdout: string; stderr: string }> => {
try {
const result = await execAsyncBase(command, options);
// Set maxBuffer to 100MB to handle large backup restore operations
// Default is 1MB which can cause "maxBuffer length exceeded" errors
const result = await execAsyncBase(command, {
...options,
maxBuffer: 100 * 1024 * 1024,
});
return {
stdout: result.stdout.toString(),
stderr: result.stderr.toString(),
@@ -54,22 +59,28 @@ export const execAsyncStream = (
let stdoutComplete = "";
let stderrComplete = "";
const childProcess = exec(command, options, (error) => {
if (error) {
reject(
new ExecError(`Command execution failed: ${error.message}`, {
command,
stdout: stdoutComplete,
stderr: stderrComplete,
// @ts-ignore
exitCode: error.code,
originalError: error,
}),
);
return;
}
resolve({ stdout: stdoutComplete, stderr: stderrComplete });
});
// Set maxBuffer to 100MB to handle large backup restore operations
// Default is 1MB which can cause "maxBuffer length exceeded" errors
const childProcess = exec(
command,
{ ...options, maxBuffer: 100 * 1024 * 1024 },
(error) => {
if (error) {
reject(
new ExecError(`Command execution failed: ${error.message}`, {
command,
stdout: stdoutComplete,
stderr: stderrComplete,
// @ts-ignore
exitCode: error.code,
originalError: error,
}),
);
return;
}
resolve({ stdout: stdoutComplete, stderr: stderrComplete });
},
);
childProcess.stdout?.on("data", (data: Buffer | string) => {
const stringData = data.toString();