Skip to content

fix(cache): restore symlinks in task outputs as links - #885

Open
jasonkuhrt wants to merge 2 commits into
voidzero-dev:mainfrom
jasonkuhrt:fix/cache-output-symlinks
Open

jasonkuhrt wants to merge 2 commits into
voidzero-dev:mainfrom
jasonkuhrt:fix/cache-output-symlinks

Conversation

@jasonkuhrt

@jasonkuhrt jasonkuhrt commented Oct 24, 2026 •

Copy link
Copy Markdown

Addresses causes 1 and 2 of #884: links an output glob matches now survive a cache hit.

Motivation

A cache hit leaves out the symbolic links in a task's outputs, so a replayed build differs from the one the task produced. Nitro's server build is one case: its dependency tracer links server/node_modules/tslib to .nf3/tslib@2.8.1, and after a hit the replayed server resolves tslib outside its own output. #884 has a minimal repro.

Changes

  • create_output_archive reads outputs with symlink_metadata and stores a link as a tar symlink entry with its target, never followed. A directory link, a file link and a dangling link round-trip as the task left them.
  • walk_glob_files passes links through to output collection; compute_globbed_inputs still takes regular files only, so input hashing is unchanged.
  • On Windows, tar restores every link with symlink_file. Extraction there unpacks as Archive::unpack does, then turns a restored link whose target is a directory into a directory link.
  • CACHE_SCHEMA_VERSION goes to 19, so entries archived without their links aren't replayed.

Restoring still refuses to write through a link that points outside the workspace (tar's unpack_in check); a test covers it.

Not covered: automatic output tracking still doesn't see a link being created (fspy has no symlink/symlinkat or CreateSymbolicLinkW interceptor), so a task needs an output glob that matches its links. #884 keeps that part open.

Output archives followed symbolic links and kept regular files only, and
output globs listed regular files only, so a cache hit dropped every link a
task's output held. Archive links as links, let output globs list them, and
restore directory links as directory links on Windows. Bump the cache schema
so entries archived without their links are not replayed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant