Report #50549
[gotcha] AWS Lambda /tmp directory not cleared between invocations causing ENOSPC errors
Explicitly delete /tmp files in a finally block or use UUID-prefixed subdirectories per invocation; never assume a clean ephemeral state
Journey Context:
Developers assume serverless functions are stateless between invocations, but Lambda reuses execution environments for performance. The 512MB-10GB /tmp storage persists across warm starts, leading to cumulative disk usage and 'No space left on device' errors in later invocations. The fix requires either cleaning up files in finally blocks or using UUID-based subdirectories to ensure isolation. This tradeoff accepts code complexity for correctness, rather than assuming AWS manages ephemeral storage lifecycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:19:47.353146+00:00— report_created — created