ducktors / turborepo-remote-cache

Open source implementation of the Turborepo custom remote cache server.
https://ducktors.github.io/turborepo-remote-cache/
MIT License
1.03k stars 95 forks source link

Unable to link to self hosted cache #146

Closed Fractal-Tess closed 1 year ago

Fractal-Tess commented 1 year ago

To Reproduce

Steps to reproduce the behavior: Host a docker container with simple local storage settings Try to link & enable cache from client via creating a .turbo/config.json with appropriate fields that include token, teamId and apiurl. Now run turbo link, and the on the client you get error: could not get team information, while on the server these logs are printed:

2023-02-21T18:16:31.570785728Z {"severity":"INFO","level":30,"time":1677003391570,"pid":7,"hostname":"09921250ff30","reqId":"Oe2v3NkCQsO6f_5DaWa91Q-14","res":{"statusCode":404},"responseTime":0.828801155090332,"message":"request completed"}
2023-02-21T18:26:52.569629705Z {"severity":"INFO","level":30,"time":1677004012568,"pid":7,"hostname":"09921250ff30","reqId":"Oe2v3NkCQsO6f_5DaWa91Q-15","req":{"method":"GET","url":"/v2/teams?limit=100","hostname":"myserver.com:36891","remoteAddress":"10.0.0.2","remotePort":52646},"message":"incoming request"}
2023-02-21T18:26:52.569669865Z {"severity":"INFO","level":30,"time":1677004012568,"pid":7,"hostname":"09921250ff30","reqId":"Oe2v3NkCQsO6f_5DaWa91Q-15","message":"Route GET:/v2/teams?limit=100 not found"}
2023-02-21T18:26:52.569674505Z {"severity":"INFO","level":30,"time":1677004012569,"pid":7,"hostname":"09921250ff30","reqId":"Oe2v3NkCQsO6f_5DaWa91Q-15","res":{"statusCode":404},"responseTime":0.45916032791137695,"message":"request completed"}

My environment

Arch 6.1.12-arch1-1 turbo@1.8.1

Edit:

Just for clarification, running turbo with cli flags like --team, --token and --api reports that it is using remote cache - ("Remote caching enabled").

fox1t commented 1 year ago

Thanks for reporting this! Can I ask you to try with client turbo@1.7.x?

Fractal-Tess commented 1 year ago

Thanks for reporting this! Can I ask you to try with client turbo@1.7.x?

Hey there and thanks for getting back to me.

I actually tried this yesterday, thinking the API might've updated on how turbo links up to the remote cache server. I cloned the code and did some logging of the incoming request, and it turns out that even though I had a .turbo/config.json with properly configured credentials, it was using the config defined in ~/.config/turbo/config.json. I suspect that config was generated when I originally connected to the official Cercel remote cache. I changed the values there and can confirm that the self-hosted remote caching server is appropriately working without using CLI arguments.

The only thing I fail to understand is why it's using the defined config in ~/.config/turbo/config.json instead of .turbo/config.json at the root of my project.

Anyway, that is all I have for now.

Fractal-Tess commented 1 year ago

I think I've figured out how this behaves.

Turborepo doesn't enable cache unless I have a ~/.config/turborepo/config.json with a token field. I also need a project root level .turbo/config.json file for teamid and apiurl.

fox1t commented 1 year ago

This should be added to the documentation. @matteovivona this is the reason we have intermittent remote cache based on the system. The Turborepo team has changed this lately.