Skip to content

Enhancement: Increase execFile buffer size in LagoonExecutor #19

Description

@coderabbitai

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:

  1. Accept an optional options parameter
  2. Set a larger default buffer size (1MB)
  3. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions