-
Notifications
You must be signed in to change notification settings - Fork 24
fix(plan): forward LOCALAPPDATA so Node's compile cache stays outside the workspace #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
crates/vite_task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/a.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const value = 'a'; |
1 change: 1 addition & 0 deletions
1
crates/vite_task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/b.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const value = 'b'; |
1 change: 1 addition & 0 deletions
1
crates/vite_task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/c.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const value = 'c'; |
5 changes: 5 additions & 0 deletions
5
...e_task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "node-compile-cache-outside-workspace-fixture", | ||
| "private": true, | ||
| "type": "module" | ||
| } |
20 changes: 20 additions & 0 deletions
20
...s/vite_task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/run.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Tiny Node script that turns on the v22 compile cache and imports a | ||
| // few sibling modules so the cache directory actually gets some files | ||
| // written to it. On a normally-configured machine the cache lives in | ||
| // the OS temp directory (outside the workspace), so the runner doesn't | ||
| // see those files when it decides whether the run can be cached. | ||
| // | ||
| // If the spawned process doesn't have LOCALAPPDATA (or TMP/TEMP/ | ||
| // USERPROFILE) set on Windows, Node ends up putting the cache inside | ||
| // the workspace, the same files are both written and read in this one | ||
| // run, and the runner refuses to cache it. That's the bug this fixture | ||
| // catches. | ||
| import { enableCompileCache } from 'node:module'; | ||
|
|
||
| enableCompileCache(); | ||
|
|
||
| await import('./a.mjs'); | ||
| await import('./b.mjs'); | ||
| await import('./c.mjs'); | ||
|
|
||
| console.log('done'); |
20 changes: 20 additions & 0 deletions
20
...task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/snapshots.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [[e2e]] | ||
| name = "node_compile_cache_does_not_poison_workspace" | ||
| comment = """ | ||
| Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its input" message. | ||
| """ | ||
| ignore = true | ||
| steps = [ | ||
| { argv = [ | ||
| "vt", | ||
| "run", | ||
| "--cache", | ||
| "build", | ||
| ], comment = "first run: cache miss" }, | ||
| { argv = [ | ||
| "vt", | ||
| "run", | ||
| "--cache", | ||
| "build", | ||
| ], comment = "second run: cache hit" }, | ||
| ] | ||
24 changes: 24 additions & 0 deletions
24
...che_outside_workspace/snapshots/node_compile_cache_does_not_poison_workspace.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # node_compile_cache_does_not_poison_workspace | ||
|
|
||
| Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its input" message. | ||
|
|
||
| ## `vt run --cache build` | ||
|
|
||
| first run: cache miss | ||
|
|
||
| ``` | ||
| $ node run.mjs | ||
| done | ||
| ``` | ||
|
|
||
| ## `vt run --cache build` | ||
|
|
||
| second run: cache hit | ||
|
|
||
| ``` | ||
| $ node run.mjs ◉ cache hit, replaying | ||
| done | ||
|
|
||
| --- | ||
| vt run: cache hit. | ||
| ``` |
8 changes: 8 additions & 0 deletions
8
...task_bin/tests/e2e_snapshots/fixtures/node_compile_cache_outside_workspace/vite-task.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "tasks": { | ||
| "build": { | ||
| "command": "node run.mjs", | ||
| "cache": true | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.