Artificial Intelligence
The Photos Weren't the Problem
A Vercel storage warning made a plan upgrade look necessary. The cause turned out to be one image-processing function that packaged every photograph into the site's server functions.
I've been adding photographs from my mountaineering archives to my portfolio. A few hundred images, several new galleries, and quite a few deployments later, I noticed my Vercel builds were taking nearly two minutes.
Then I received a storage warning. I'd exceeded the 10 GB Functions Storage allowance on my Hobby plan. Upgrading to Pro would cost $20/month.
That seemed excessive for a mostly static photography collection.
I started investigating with ChatGPT, looking at the usage metrics and recent development activity. The timing suggested the new photography galleries were responsible, but it wasn't clear why. I subsequently brought Claude Code into the investigation to inspect the repository and compare production-equivalent builds.
We found the culprit in a single image-processing function.
The site used Sharp to read photographs and determine their dimensions. Because Next.js couldn't resolve which files the function might need, its output tracing included the entire public/ directory and Sharp in nine separate server functions.
Each deployment was carrying approximately 2.2 GB of function bundles.
And with dozens of deployments during the gallery work, that added up rather quickly.
The photographs weren't inherently too large. We were just packaging them into functions that didn't need them.

Figure 1. Compressed server function bundles per deployment, before and after the fix.
The fix
We moved image-dimension extraction to build time, generating a 29 KB manifest containing dimensions for 379 images and references to seven videos.
We then excluded the public assets from server function tracing and added a build validation check to catch the problem if it returned.
No photographs were moved, recompressed, or removed. No additional storage provider was necessary.
The results
| Metric | Before | After |
|---|---|---|
| Server functions | 9 | 2 |
| Compressed function bundles | 1,845 MB | 1.71 MB |
| Production build time | ~2 minutes | 32 seconds |
| Site images and videos | 379 images, 7 videos | Unchanged |
| Additional monthly cost | $20 upgrade considered | $0 |
The implementation passed the existing tests, CI validation, and production smoke tests. All 31 sitemap URLs returned successfully, the galleries and videos rendered normally, and the new function-tracing check confirmed no photography assets were included in the server bundles.
After verifying the fix in production, we removed 47 obsolete deployments, reducing stored function bundles from 33.07 GB to 1.85 GB. The remaining storage is almost entirely the previous production deployment, which we're retaining temporarily for rollback.

Figure 2. Post-deployment cleanup removed 47 obsolete deployments, reducing stored function bundles by 94.4%.
The investigation took us from a possible subscription upgrade to a targeted code change that reduced function bundle storage by more than 99% and cut build time considerably.