Vercel Bun serverless functions crash with exit status 1 when using path aliases

I have a simple REST API setup here: GitHub - DarkstarXDD/hono-bun-on-vercel

It’s basically the same setup as shown in the official example.

Problem

The only difference is that I have couple of extra routes defined and they are imported into the main entry file, which is src/app.ts. According to the docs here, Vercel will automatically pick up src/app.ts as an entry point so that is not an issue.

When deployed, the build succeeds. However, every single route is crashing at runtime.

Current Behavior

The error I get in the runtime logs is:

ResolveMessage {} Bun process exited with exit status: 1. The logs above can help with debugging the issue.

I tried adding an app.onError in Hono, but that doesn’t seem to hit either. So it’s crashing even before that.

What I’ve Tried

This was the only thread I found regarding this issue: Elysia and Bun serverless function fails with exit status 1 on Vercel

Since it mentions the issue is because of path aliases, I tried removing the path aliases and replacing them with relative imports. It works then. The serverless functions don’t crash.

However, the actual repo I want to deploy has many imports on each file using path aliases. I would really like to know whether there is a solution for this without removing all my path aliases.

I also tried a few different solutions in this branch: Comparing main…fix-vercel-crash

  1. Added a bun build script to package.json:
"build": "bun build ./src/app.ts --outdir ./dist"
  1. Updated vercel.json as follows:
{
  "bunVersion": "1.x",
  "routes": [{ "src": "/(.*)", "dest": "/dist/app.js" }]
}

This gave the same result where the serverless function crashes. I am not sure what I may have done wrong there.

Could you try the following?

  • Replace all path alias imports (@/*) with relative imports (./ or ../) - this is the most reliable fix
  • Use explicit file extensions in imports (.ts, .tsx) as Bun sometimes requires them

Let us know how you get on!