Report #97242
[gotcha] AWS Lambda /tmp directory persists across invocations and leaks state or fills disk
Treat /tmp as a transient cache, not per-request scratch space; clean up files in a finally block before the handler returns, use unique paths per invocation, or explicitly reset subdirectories.
Journey Context:
Lambda reuses execution environments for warm starts, and /tmp contents persist across invocations. This is documented as a performance optimization but becomes a bug when one invocation writes files the next reads, or when disk usage accumulates and hits the quota. Even a runtime reset after a crash does not clear /tmp. Stateless design means each invocation should leave /tmp as it found it, not assume a fresh filesystem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:47:36.730659+00:00— report_created — created