Skip to content

Bump Lambda to 4096 MB and cap Node.js heap to prevent OOM#2546

Merged
hiroshinishio merged 1 commit intomainfrom
wes
Apr 17, 2026
Merged

Bump Lambda to 4096 MB and cap Node.js heap to prevent OOM#2546
hiroshinishio merged 1 commit intomainfrom
wes

Conversation

@hiroshinishio
Copy link
Copy Markdown
Collaborator

@hiroshinishio hiroshinishio commented Apr 17, 2026

Summary

  • Bump Lambda memory from 3072 to 4096 MB to prevent frequent OOM kills during Jest + MongoMemoryServer runs
  • Read memory limit from AWS runtime env var (AWS_LAMBDA_FUNCTION_MEMORY_SIZE) instead of hardcoding, so infra changes auto-propagate
  • Cap Node.js V8 heap via NODE_OPTIONS=--max-old-space-size (Lambda memory minus 1.5 GB reserved for Python + mongod + OS), so Jest fails with a catchable JS error instead of killing the Lambda
  • Update LGTM workflow: user stages files before saying "lgtm", remove separate git add step

Social Media Post (GitAuto)

Cap Node.js heap to prevent Lambda OOM during Jest runs

  • Lambda memory bumped from 3 GB to 4 GB
  • Node.js heap capped so Jest crashes gracefully instead of killing the Lambda
  • Memory limit now reads from AWS runtime env var instead of being hardcoded

Social Media Post (Wes)

Our Lambda kept dying mid-Jest run. MongoMemoryServer plus a big import chain ate all 3 GB. Bumped to 4 GB and capped Node.js heap so it throws a catchable error instead of silently killing the whole process. The real lesson: if your subprocess can eat unbounded memory, cap it at the OS level, don't trust application-level limits alone.

@hiroshinishio hiroshinishio self-assigned this Apr 17, 2026
@hiroshinishio hiroshinishio merged commit a9f0c30 into main Apr 17, 2026
1 check passed
@hiroshinishio hiroshinishio deleted the wes branch April 17, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant