Vercel integration adds config variables too late when new branch is pushed

When I push a new branch to GitHub:

  1. Vercel’s GitHub integration gets notified about the new branch and queues a build
  2. Neon’s Vercel integration gets notified about the new preview environment and creates a database branch
  3. Neon adds a new DATABASE_URL for the new branch & preview environment.

The problem we’ve been noticing is that the Vercel build starts before #3 can complete, so the first build of a new branch usually ends up failing due to the missing variable:

Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:10
   | 
 9 |   provider = "postgresql"
10 |   url      = env("DATABASE_URL")
   | 
Validation Error Count: 1
[Context: getConfig]
Prisma CLI Version : 4.15.0
Error: Command "npm run vercel-build" exited with 1

We don’t have a default preview DATABASE_URL (nor would we want one), and our build runs prisma migrate deploy as its last step, so we do need the preview environment’s actual database branch config.

It’s very annoying to have to go to in to Vercel and trigger a rebuild every time a new branch is pushed. How can I ensure that new branches don’t fail to build?

3 Likes

Hey @josh3736! Thank you for reaching out.

We’re aware of this issue, and we understand that it’s very inconvenient.

We’re working closely with the Vercel team this gets fixed. Unfortunately, there are no workarounds at the moment. I will let you know when the issue is resolved.

Alternatively, you can achieve a similar flow using GitHub actions. It requires a bit more setup upfront, but you shouldn’t encounter any issues.

You can check out the following guide: A database for every preview environment using Neon, GitHub Actions, and Vercel - Neon

Feel free to reach out if you have any questions about this flow. I’d be happy to help

Any idea when you might have the integration fixed?

I’d rather not invest time in building a custom setup.

1 Like

Hey @josh3736. Apologies for the super late response. Unfortunately, there isn’t an exact ETA for fixing this issue.

I’d rather not invest time in building a custom setup.

Have you checked out the guide I shared above? A database for every preview environment using Neon, GitHub Actions, and Vercel - Neon. Also happy to answer any questions you might have

Having the same issue where the build fails due to missing environment variable. The guide you shared about is great @Mahmoud , but I’m not keen on maintaining a GitHub Actions workflow just to get this working.

Do you have any new ETA for resolving this issue? Thanks!

1 Like

Hey @Mahmoud. We’re starting a new project, and this gap leaves us out in the lurch a bit: if we use Neon and want to run migrations, that means we have to basically opt out of everything Vercel does, and instead use Github Actions as CI/CD. This issue has been open since June, we’re coming up on November… Is there any chance resolution can be expedited?

1 Like

Hey @Steven, we’re working with Vercel on fixing the integration’s rough edges with the goal of making it GA. Unfortunately, we don’t have an exact ETA yet. Hopefully we can share an update soon

Guys, this bug exists since half a year soon. This is really annoying. When will you have finally resolved this?

I’m the PM for this. Thank you for your continued patience. We plan to release improvements to the integration before year-end. This particular issue is tricky because both Neon and Vercel need to make changes simultaneously without disrupting anyone’s workflow. We are working on it, investigating solutions for a smooth resolution. Feel free to reach out to me directly at mike@neon.tech if you’d like to chat in more detail.