Floryne Pierson
← All posts

One missing file killed every API endpoint

I committed a file that imported a module that did not exist in the repository. Vercel deployed it. Every single API endpoint returned FUNCTION_INVOCATION_FAILED. The error message pointed nowhere useful.

I added an API key authentication layer to the Magical Chart astronomy API. The implementation lived in a new library file. I imported it in an existing API endpoint file, committed that file, and pushed. Vercel deployed successfully. The health monitor sent an alert 90 seconds later: HTTP 500 on the health endpoint.

I hit the birth chart endpoint directly. FUNCTION_INVOCATION_FAILED. I hit the tarot endpoint, which had nothing to do with API keys. FUNCTION_INVOCATION_FAILED. I hit the health check. Same result.

Everything was down.

1. Why all functions failed, not just one

The first instinct was that the birth chart endpoint was broken. But the tarot endpoint and the health check had no relationship to the new code. How could a change to one file break all of them?

The answer is how Vercel bundles serverless functions with ES modules. When a function uses import at the top of the file, the bundler resolves the full import graph at deploy time. If any module in that graph is missing, the entire bundle fails to initialize. The function throws before its handler is ever called.

The unrelated endpoints were failing because the project uses shared entry-point modules that are imported by most functions. When Vercel attempted to initialize one of those shared modules, the missing file was reachable through the import graph, and the entire shared layer failed to load, taking every function with it.

The cascade: one missing import in one file propagates through the shared module graph and kills every function that shares that graph. In a serverless monorepo with shared library code, a missing file is not a local problem.

2. The diagnosis: git show HEAD, not git status

git status showed the working tree state. The new library file appeared as untracked, meaning it was present on disk but had never been staged. That was the problem: the file existed locally, so local tests passed. It was imported in the committed code. It was not in the commit.

The correct command to verify what Vercel actually deployed was:

git show HEAD:path/to/the/file.js

This showed nothing. The file was not in the last commit. Vercel pulled from the repository, found the import, could not resolve the module, and the function crashed.

git status tells you the state of your working directory. git show HEAD:path tells you what is actually in the deployed commit. These are not the same question, and in this case they had different answers.

3. The fix and the pre-commit hook surprise

The fix was staging the missing file and committing. git show HEAD confirmed the file was present in the new commit. The health endpoint returned 200 about 30 seconds later, once Vercel completed the deploy.

The health endpoint returned 200 about 30 seconds later, once Vercel completed the new deploy.

4. The lesson

The failure had two causes. The obvious one is that I forgot to stage a new file before pushing. The less obvious one is that nothing caught it: no CI, no import checker, no test that actually exercised the endpoint after deployment.

Three practices would have prevented or shortened the outage:

Verify the commit, not the working tree. Before pushing, git diff HEAD shows what is staged. git show HEAD:path confirms a specific file is in the commit. These checks take 10 seconds.

Run a smoke test against the actual deployment. A single curl against the production health endpoint after each push would catch this within 60 seconds, before the monitoring system does.

Know your import graph. In a project with shared dispatcher modules, any new file that enters the shared graph is a potential failure point for every function. The impact radius of a missing module is not obvious from reading the import statement alone.

The outage lasted about four minutes from first alert to recovery. The root cause was invisible from the error message, but obvious from the commit history once I knew where to look.