How to stop Vercel from injecting and overriding the TURBO_TOKEN env var

I am trying to setup custom remote caching for Turborepo on vercel builds.

So far the behavior I’m seeing is that Vercel will override the TURBO_TOKEN environment variable even if we specify it outselves in the project settings.

I made a project to test this with the Turborepo & Next.js Starter – Vercel starter kit and specified all the envs

However, I’ve confirme that the value of TURBO_TOKEN is overriden consistently.

Is there a way around this?

The sample project I made has this ID prj_OG4EOYUd0XEileI17kbkiCWNxIdv (in case that’s useful)

1 Like

Hi,

I don’t think we support custom remote caching server. Is there a particular tutorial you are following?

Hey @swarnava , thanks for the quick reply :slightly_smiling_face:.

When you say “we don’t support custom remote caching server”, I assume you mean within the Vercel build itself right? Turborepo definitely supports it - Remote Caching | Turborepo

I’m asking because I have an OSS project for running custom remote cache servers for turborepo on Cloudflare, and someone brought up that they were unable to connect their Vercel builds to it - [Bug]: Custom remote cache builds cannot be triggered on Vercel · Issue #651 · AdiRishi/turborepo-remote-cache-cloudflare · GitHub

Just to make sure I understand correctly, within the Vercel build environment, this won’t be possible?

@adirishi Caching is automatically configured for turbo repo when building to Vercel, the CI tokens are only needed for external CIs like GitHub Actions

Yup, I get that. But in case someone wanted to use a different remote cache location (e.g their own server), how can we support that in Vercel builds?
I think it seems reasonable that if the TURBO_TOKEN value is provided by the user themselves, that it shouldn’t be overriden by the build env.

@adirishi Custom remote caching | Turborepo Remote Cache ducktors has a turbo remote cache impl that you can use and point to by chainging the turbo config to allow you to use a non Vercel server

1 Like

@swarnava @versecafe Sorry, maybe I haven’t explained myself clearly - I already have a working remote cache server.

The issue here is that when you setup your CI pipeline in Vercel, AKA using Vercel builds and deploymnets, the build system does not respect the value of TURBO_TOKEN that I provide in project envs.
Instead, it will override that value.

The question and point of discussion here is, I consider this to be bad / buggy behavior. I believe if the value of TURBO_TOKEN is provided by the user, Vercel should avoid overriding it with their own value in builds.

We can actually see this in the build logs as well, Vercel will output

> Detected Turbo. Adjusting default settings...

I appreciate your detailed sharing of information. It seems that Turborepo on Vercel doesn’t utilize the TURBO_TOKEN environment variable, but instead employs a different token that is configured automatically within the build pipeline. I have noticed a potential issue here, where the system is not prioritising the search for TURBO_TOKEN.

To address this, I have initiated an internal ticket. Thank you for bringing this to our attention.

1 Like

@swarnava thanks for looking into this. That definitely explains the behavior I’m seeing.

Is there any way for me to track the progress of this ticket or get an idea of the timeline? Would love to say updated on this.

1 Like

Hi,

Unfortunately, it’s being tracked internally and the portal isn’t available to the public. Our team has already started discussing how to handle this situation better. Thanks!

1 Like

Definitely would love to get updated on this! Thank you for looking into it

Hi there,

We have released Turborepo v2.2.3 to address this. Let me know if you still experiencing this problem.

3 Likes

Hey @swarnava I just re-tested this. Vercel still isn’t respecting the value of the TURBO_TOKEN environment variable in builds.
It’s instead replacing it with a JWT value which I assume is supposed to be used by Vercel internally.

Hi @adirishi , can you confirm if you are using latest version of turbo to reproduce this again? FWIW, we can’t actually do anything with TURBO_TOKEN all on its own. We need one or both of TURBO_TEAM and/or TURBO_TEAMID

Ahh, my bad, I indeed forgot to upgrade turborepo.
I can confirm your fix is working! Thank you so much for helping debug and fix this @swarnava :pray:

For anyone curious, I tested the fix works with turbo version 2.2.3

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.