·StoryRoll

The Sitemap That Crashed Every Hour

On October 28, 2026, I found out our sitemap had been crashing in production since August 11. That is 79 days. The error was one line:

ENOENT: no such file or directory, open '/var/task/content/seo-title-exemptions.json'

The runtime error log showed a single group on the sitemap route: 316 occurrences, 69 users in the last seven days. It was still firing on the current deployment.

How a file goes missing

On August 8 we merged a change that made src/lib/blog.ts read a small JSON file of SEO title exemptions. It used fs.readFileSync, at module load. Locally that works every time. During the build it works too, because the whole repo is sitting right there.

The sitemap is different. It regenerates every hour, and it does that inside a serverless function. That function does not get the repo. It gets the bundle, plus whatever files our outputFileTracingIncludes entry for the sitemap lists. Ours listed the blog posts and the tools pages. It did not list the JSON.

So every hourly rebuild threw before it produced anything. Crawlers got a stale copy or a 500.

Why I looked

Starting in late August, Bing-family traffic to our best pages roughly halved. The homepage, the "tested every AI dungeon master" post, and the best AI for D&D 2026 post. Google held steady. Bing leans hard on sitemaps. I had already shipped one fix for that drop, a deploy hook that submits changed posts directly. It helped with new posts. It could not fix a sitemap that never finished building.

The fix, and the choice inside it

There were two ways out. Add the JSON to the tracing list, one line. Or replace the file read with a static import, so the bundler ships the data with every route that uses blog.ts.

I took the import. The tracing line would have worked today and broken the next time anyone added a file read to a module the sitemap touches. An import cannot drop out of a trace.

The other half of the PR is a test. It copies only the files our config traces for the sitemap into a temp directory, points process.cwd() there (which is what the serverless function sees), runs the sitemap's default export, and asserts every blog post URL shows up. On the old code it fails with the exact production error. On the new code it passes. Because it reads the globs from next.config.ts, a narrowed glob trips it too.

I also checked the other readers. The SEO length script still uses fs, and that is fine, since it runs after the build from the repo root.

What I can prove

The new test fails before the change and passes after. npm run verify is green. That is all I can prove today, because production behavior only shows up after the deploy. The checklist for after it ships: the error group stops getting hits, the sitemap returns 200 with every post, and I resubmit it to Bing and Google by hand.

What I can't

The timing fits. The crash starts August 11, the traffic starts sliding in late August, and the sitemap is the thing Bing reads. But a crash that left stale copies in place does not obviously explain a halving, and I have two causes now where I wanted one.

The fix is merged. I still don't know if Bing noticed the crash, or just stopped caring.

S

Written by StoryRoll

Founder of StoryRoll. Building AI-powered tabletop RPGs.

Share:Share on X

Related Posts