Skip to content

Keep relative symlinks relative in NodeFileSystem.copy - #11011

Open
Marve10s wants to merge 1 commit into
Effect-TS:mainfrom
Marve10s:fix/node-fs-copy-relative-symlinks
Open

Marve10s wants to merge 1 commit into
Effect-TS:mainfrom
Marve10s:fix/node-fs-copy-relative-symlinks

Conversation

@Marve10s

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

On Node.js and Bun, FileSystem.copy turns every relative symlink in a copied tree into an absolute link pointing back into the source. After copying app -> app-v1, the copy's app points at <source>/app-v1, so the copy still depends on the source and reading through the link fails with NotFound once the source is removed or moved. Copying a tree again into an existing copy also fails with ERR_FS_CP_EINVAL ("cannot copy ... to a subdirectory of self") when the tree contains a relative link to a directory.

The Node adapter calls fs.cp with recursive: true and leaves verbatimSymlinks at Node's default of false, which makes Node rewrite relative link targets. FileSystem.copy is documented as equivalent to cp -r, and cp -r, cp -R and the Deno implementation keep the link text. Passing verbatimSymlinks: true keeps relative links relative in the shared adapter, so Bun gets the fix too. As with cp -r, copying a single relative link on its own into another directory now keeps its relative target, which may not resolve there.

Verification

The same probe on both versions copies a directory containing app -> app-v1, then removes the source:

effect@4.1.7 / @effect/platform-node@4.1.7 and main:
Effect link: absolute path into source
cp -R link: app-v1
Effect read after source removal: NotFound
cp -R read after source removal: from the build

this branch:
Effect link: app-v1
cp -R link: app-v1
Effect read after source removal: from the build
cp -R read after source removal: from the build

The new test in the shared FileSystem suite fails without the fix on Node and Bun (the copied link points into the source) and passes with it; it also passes on Deno. Root pnpm check and pnpm lint passed, and the Node, node-shared and Bun platform tests passed (1,101 tests).

@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 54c3b6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@effect/platform-node-shared Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-cloudflare Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.28 KB 40.28 KB 0.00 KB (0.00%)
basic.ts 6.60 KB 6.60 KB 0.00 KB (0.00%)
batching.ts 11.65 KB 11.65 KB 0.00 KB (0.00%)
brand.ts 7.17 KB 7.17 KB 0.00 KB (0.00%)
cache.ts 11.83 KB 11.83 KB 0.00 KB (0.00%)
config.ts 23.75 KB 23.75 KB 0.00 KB (0.00%)
differ.ts 22.55 KB 22.55 KB 0.00 KB (0.00%)
http-client.ts 28.40 KB 28.40 KB 0.00 KB (0.00%)
http-router.ts 39.10 KB 39.10 KB 0.00 KB (0.00%)
logger.ts 12.26 KB 12.26 KB 0.00 KB (0.00%)
metric.ts 9.91 KB 9.91 KB 0.00 KB (0.00%)
optic.ts 7.43 KB 7.43 KB 0.00 KB (0.00%)
pubsub.ts 16.55 KB 16.55 KB 0.00 KB (0.00%)
queue.ts 13.44 KB 13.44 KB 0.00 KB (0.00%)
schedule.ts 12.27 KB 12.27 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.32 KB 14.32 KB 0.00 KB (0.00%)
schema-binary.ts 43.17 KB 43.17 KB 0.00 KB (0.00%)
schema-class.ts 22.31 KB 22.31 KB 0.00 KB (0.00%)
schema-codegen.ts 33.66 KB 33.66 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.76 KB 30.76 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.49 KB 28.49 KB 0.00 KB (0.00%)
schema-string-transformation.ts 16.06 KB 16.06 KB 0.00 KB (0.00%)
schema-string.ts 12.60 KB 12.60 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.62 KB 16.62 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.82 KB 39.82 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.44 KB 21.44 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.62 KB 21.62 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.71 KB 21.71 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.75 KB 26.75 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.77 KB 21.77 KB 0.00 KB (0.00%)
schema.ts 21.41 KB 21.41 KB 0.00 KB (0.00%)
stm.ts 14.77 KB 14.77 KB 0.00 KB (0.00%)
stream.ts 10.56 KB 10.56 KB 0.00 KB (0.00%)
supervisor.ts 11.85 KB 11.85 KB 0.00 KB (0.00%)

This branch is waiting to be deployed

1 waiting deployment
fork — 54c3b6ce Waiting Nov 27, 2026 by Marve10s via approval-gate #27807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant