turbo icon indicating copy to clipboard operation
turbo copied to clipboard

turbo run --dry=json says cache.local=false yet when I run the task, it says cache hit

Open BenjaminVanRyseghem opened this issue 1 year ago • 6 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/BenjaminVanRyseghem/turbo-bug

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

2.0.15-canary.2

Describe the Bug

As explained here on our CI, I end up in a situation where the dry run tells me there is no local cache (even though it is restored via a prior step), but when I run the actual task, it's a full turbo.

Expected Behavior

I am expecting both to be coherent, so that I can rely on the --dry=json parameter to know when to skip CI steps

To Reproduce

I managed to reproduce it locally as you can see in the following screenshot, using this repo

Screenshot 2024-08-22 at 11 16 32

Additional context

No response

BenjaminVanRyseghem avatar Aug 22 '24 09:08 BenjaminVanRyseghem

outputs already on disk means the cache wasn’t even checked in the real run. The daemon was watching the outputs for your task, and they didn’t change since the last run, so it assumes that it’s a cache hit. In this scenario it is plausible there is no cache entry for the run, but we still get a “cache hit”.

Maybe it should say “cache bypass” (like it does when using the - - force flag, albeit for the opposite reason)

mehulkar avatar Aug 30 '24 20:08 mehulkar

Thanks.

That is not the message we got in the original issue, in our CI.

The message is

package1:build: cache hit, replaying logs 74f0d18029cb48a5

So I guess it's a bit different.

The dry-run output something like

{
  // tons of files
  "hashOfExternalDependencies": "79d18c12d5940eb5",
  "cache": {
    "local": false,
    "remote": false,
    "status": "MISS",
    "timeSaved": 0
  },
  "command": "webpack --progress",
  "cliArguments": [],
  "outputs": null,
  "excludedOutputs": null,
  "logFile": "apps/client/.turbo/turbo-build.log",
  "directory": "apps/client",
  "dependencies": [
    "@foretagsplatsen/client#transit"
  ],
  "dependents": [],
  "resolvedTaskDefinition": {
    "outputs": [],
    "cache": true,
    "dependsOn": [
      "transit"
    ],
    "inputs": [],
    "outputLogs": "full",
    "persistent": false,
    "env": [],
    "passThroughEnv": null,
    "interactive": false
  },
  "expandedOutputs": [],
  "framework": "create-react-app",
  "envMode": "strict",
  "environmentVariables": {
    "specified": {
      "env": [],
      "passThroughEnv": null
    },
    "configured": [],
    "inferred": [],
    "passthrough": null
  }
}

but we I run the task, I got

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    475ms >>> FULL TURBO

Done in 0.85s.

BenjaminVanRyseghem avatar Aug 30 '24 21:08 BenjaminVanRyseghem

As Mehul explained above, for local runs with the daemon this is expected behavior since outputs haven't change so nothing needs to be restored from cache.

A few follow up questions:

  • Is remote cache enabled for either the --dry=json run or the real run? (i.e. is TURBO_TOKEN set?)
  • Can you provide a reproduction (or the equivalent shell commands) of your CI setup?

chris-olszewski avatar Sep 03 '24 16:09 chris-olszewski

I am noticing this same issue. Opening up a broader issue and will reference this one

jakeleventhal avatar Feb 27 '25 17:02 jakeleventhal

Also having this issue

dBianchii avatar Feb 27 '25 17:02 dBianchii

As Mehul explained above, for local runs with the daemon this is expected behavior since outputs haven't change so nothing needs to be restored from cache.

A few follow up questions:

  • Is remote cache enabled for either the --dry=json run or the real run? (i.e. is TURBO_TOKEN set?)
  • Can you provide a reproduction (or the equivalent shell commands) of your CI setup?

I have remote cache enabled for both cases. I am producing this locally, not on CI.

It is showing cache misses for both remote and local in the dry run.

See https://github.com/vercel/turborepo/issues/10055 for more information here.

jakeleventhal avatar Feb 28 '25 13:02 jakeleventhal