Report #21593
[gotcha] Intl.DateTimeFormat instances cause memory leaks when not cached and timezone contamination across requests in serverless
Cache formatters by locale\+timezone\+options key using a Map or LRU; never create per-request formatters; clear cache on locale changes; validate locales with Intl.DateTimeFormat.supportedLocalesOf before caching
Journey Context:
V8 optimizes Intl objects by caching internal locale data structures, but creating unique formatters exhausts this cache. In serverless, repeated instantiation leaks memory across invocations because the V8 isolate persists. Additionally, formatters cache the resolved options including the system timezone at creation time; creating a formatter at module init \(top-level\) and the serverless environment changing timezone between cold starts yields stale data. The tradeoff is memory vs CPU: caching uses memory but avoids re-parsing locale data. Implement a bounded cache \(LRU\) to prevent unbounded growth from dynamic locale strings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:39:42.797991+00:00— report_created — created