Commit 8bc41ae
fix: disable Next image on-disk cache on read-only Lambda
Next 16's image optimizer eagerly initializes a disk LRU cache in its
constructor, calling mkdir('.next/cache/images') at runtime. On Netlify's
read-only Lambda filesystem (/var/task) this mkdir fails with ENOENT, and
because the init promise is created eagerly and not awaited/caught at that
point, it surfaces as an unhandled promise rejection in the
___netlify-server-handler function.
Set images.maximumDiskCacheSize to 0 so the disk cache is never
initialized (isDiskCacheEnabled stays false, getOrInitDiskLRU is never
called). The local disk cache is useless on ephemeral read-only functions
anyway -- optimized images are served via Netlify's image CDN
(NEXT_FORCE_EDGE_IMAGES).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9e2acee commit 8bc41ae
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
| |||
0 commit comments