Problem
The current implementation of LagoonExecutor.execute() uses Node.js's child_process.execFile with default options, which limits the buffer size to 200KB. When running commands like lagoon list projects --output-json on busy instances, this buffer can be exceeded, causing the promise to reject with ERR_CHILD_PROCESS_STDIO_MAXBUFFER.
Proposed Solution
Modify the execute method to:
- Accept an optional
options parameter
- Set a larger default buffer size (1MB)
- Allow callers to override options when needed
async execute(command, action = 'Unknown Action', options = {}) {
const baseCommand = command.getBaseCommand();
const args = command.getArgs();
console.log(chalk.blue(`Executing: ${chalk.bold(command.toString())}`));
try {
const defaultOptions = { maxBuffer: 1024 * 1024 }; // 1 MB
const result = await this.execFileAsync(
baseCommand,
args,
{ ...defaultOptions, ...options }
);
// Rest of the function remains the same
Benefits
- Prevents buffer overflow errors with large command outputs
- Provides flexibility for callers to adjust buffer size based on expected output
- Maintains backward compatibility with existing code
References
Problem
The current implementation of
LagoonExecutor.execute()uses Node.js'schild_process.execFilewith default options, which limits the buffer size to 200KB. When running commands likelagoon list projects --output-jsonon busy instances, this buffer can be exceeded, causing the promise to reject withERR_CHILD_PROCESS_STDIO_MAXBUFFER.Proposed Solution
Modify the
executemethod to:optionsparameterBenefits
References