Skip to content

fix: add maxBuffer 10MB to execFileAsync calls in routes.ts - #615

Merged
gopaljilab merged 2 commits into
gopaljilab:mainfrom
KaparthyReddy:fix/exec-file-max-buffer
Jun 2, 2026
Merged

gopaljilab merged 2 commits into
gopaljilab:mainfrom
KaparthyReddy:fix/exec-file-max-buffer

Conversation

@KaparthyReddy

Copy link
Copy Markdown
Contributor

Description

execFileAsync was called with no maxBuffer option on both the preview (POST /api/assessments/preview) and full assessment (POST /api/assessments) endpoints:

const { stdout, stderr } = await execFileAsync(
  getPythonExecutable(),
  [analyzePyPath, "predict_file", tempFile],
  {
    timeout: 30000
  }
);

Node.js execFile defaults to a maxBuffer of 1MB for stdout. In production environments where ML libraries (scikit-learn, numpy) print initialization warnings, deprecation notices, or model loading logs, stdout can exceed 1MB — causing the process to crash with ERR_CHILD_PROCESS_STDIO_MAXBUFFER. This error is silently caught by the outer catch block and returned as a generic 500 to the user with no indication of the root cause.

Changes made:

  • Added maxBuffer: 10 * 1024 * 1024 (10MB) to both execFileAsync calls — the preview endpoint (line 561) and the full assessment endpoint (line 650)
  • Added a comment explaining why the buffer is set explicitly
  • Verified zero TypeScript errors with npx tsc --noEmit

Fixes #476

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

- execFileAsync was called with no maxBuffer option on both the
  preview and full assessment endpoints, defaulting to Node.js's
  1MB stdout limit
- Verbose Python output (scikit-learn/numpy deprecation warnings,
  model loading logs) can exceed 1MB causing ERR_CHILD_PROCESS_STDIO_MAXBUFFER
  which is silently caught and returned as a 500 to the user
- Set maxBuffer to 10 * 1024 * 1024 (10MB) on both execFileAsync
  calls to safely handle verbose Python stdout without crashing

Fixes gopaljilab#476
@github-actions github-actions Bot added gssoc:approved level:critical Urgent issues requiring immediate attention. type:bug Something isn't working or throwing errors. labels Jun 2, 2026
@gopaljilab
gopaljilab merged commit 59f242e into gopaljilab:main Jun 2, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved level:critical Urgent issues requiring immediate attention. type:bug Something isn't working or throwing errors.

Projects

None yet

2 participants