René's URL Explorer Experiment


Title: `fs.cp` creates file symlink instead of directory symlink on Windows when `filter` is provided · Issue #62653 · nodejs/node · GitHub

Open Graph Title: `fs.cp` creates file symlink instead of directory symlink on Windows when `filter` is provided · Issue #62653 · nodejs/node

X Title: `fs.cp` creates file symlink instead of directory symlink on Windows when `filter` is provided · Issue #62653 · nodejs/node

Description: Version v24.14.1 (also affects v25.9.0) Platform Windows 11 Pro 10.0.26200 What steps will reproduce the bug? import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; const tmp = path.join(os.tmpdir(), 'repro-' +...

Open Graph Description: Version v24.14.1 (also affects v25.9.0) Platform Windows 11 Pro 10.0.26200 What steps will reproduce the bug? import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; const...

X Description: Version v24.14.1 (also affects v25.9.0) Platform Windows 11 Pro 10.0.26200 What steps will reproduce the bug? import fs from 'node:fs'; import path from 'node:path'; import os from ...

Opengraph URL: https://github.com/nodejs/node/issues/62653

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`fs.cp` creates file symlink instead of directory symlink on Windows when `filter` is provided","articleBody":"### Version\n\nv24.14.1 (also affects v25.9.0)\n\n### Platform\n\nWindows 11 Pro 10.0.26200\n\n### What steps will reproduce the bug?\n\n```javascript\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nconst tmp = path.join(os.tmpdir(), 'repro-' + Date.now());\nconst src = path.join(tmp, 'src');\nconst dest1 = path.join(tmp, 'dest-no-filter');\nconst dest2 = path.join(tmp, 'dest-with-filter');\n\n// Create a source directory with a relative directory symlink\nfs.mkdirSync(path.join(src, 'packages', 'my-lib'), { recursive: true });\nfs.writeFileSync(path.join(src, 'packages', 'my-lib', 'index.js'), 'hello');\nfs.mkdirSync(path.join(src, 'linked'), { recursive: true });\nfs.symlinkSync(\n  path.join('..', 'packages', 'my-lib'),\n  path.join(src, 'linked', 'my-lib'),\n  'dir'\n);\n\n// Test 1: verbatimSymlinks WITHOUT filter — works\nfs.cpSync(src, dest1, { recursive: true, verbatimSymlinks: true });\nconsole.log('without filter:', fs.statSync(path.join(dest1, 'linked', 'my-lib')).isDirectory()); // true\n\n// Test 2: verbatimSymlinks WITH filter — broken\nfs.cpSync(src, dest2, { recursive: true, verbatimSymlinks: true, filter: () => true });\nconsole.log('with filter:', fs.statSync(path.join(dest2, 'linked', 'my-lib')).isDirectory()); // EPERM\n\nfs.rmSync(tmp, { recursive: true, force: true });\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways reproducible on Windows. Requires `verbatimSymlinks: true` combined with a `filter` function (even `() => true`).\n\n### What is the expected behavior? Why is that the expected behavior?\n\nBoth cases should produce a working directory symlink. The `filter` option should not affect the symlink type — `filter: () => true` is semantically identical to no filter.\n\n### What do you see instead?\n\nWithout `filter`: the directory symlink is preserved correctly (`Directory, ReparsePoint`).\n\nWith `filter`: a file symlink is created instead (`Archive, ReparsePoint`). Subsequent `stat()`, `readdir()`, and `realpathSync()` on the copied symlink all fail with `EPERM`.\n\n### Root cause\n\n`fs.cp` takes two different code paths depending on whether `filter` is provided:\n\n- **Without `filter`**: Uses the C++ fast path (`fsBinding.cpSyncCopyDir`) which calls `std::filesystem::copy_symlink()` — this automatically preserves the symlink type.\n\n- **With `filter`**: Falls back to the JavaScript path in `lib/internal/fs/cp/cp-sync.js`, where `onLink()` calls `symlinkSync(resolvedSrc, dest)` **without the `type` parameter**.\n\nWhen `type` is omitted, `symlinkSync` tries to auto-detect by calling `statSync(resolve(dest, '..', target))`. However, during a recursive copy, the symlink's target directory may not yet exist at the destination (e.g., `linked/` is copied before `packages/` in alphabetical order). When stat fails, `type` defaults to `null`, which results in a **file symlink** on Windows.\n\nThe same issue exists in the async version (`lib/internal/fs/cp/cp.js`).\n\n### Related Issue\n\n- https://github.com/vitejs/vite/pull/22196#discussion_r3056981191","author":{"url":"https://github.com/shulaoda","@type":"Person","name":"shulaoda"},"datePublished":"2026-04-09T16:15:39Z","url":"https://github.com/nodejs/node/issues/62653"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:43787496-cb90-4a6a-8bab-f120d8923011
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCCFA:1E2715:60ECCB:7D76F4:6AED2ACC
html-safe-nonce7f70f6eb3de1296ba72b1033daecdcd2e2baf06b4a0441534c97e651da600051
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0ZBOjFFMjcxNTo2MEVDQ0I6N0Q3NkY0OjZBRUQyQUNDIiwidmlzaXRvcl9pZCI6IjcxODgwNjMxNjg2MzAwNzQzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1d8b5abd41d444f0c657abe711687c5854d90f1f272604ea5a7d0e7231c1412d
hovercard-subject-tagissue:4233541029
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/62653/issue_layout
twitter:imagehttps://opengraph.githubassets.com/55051d812b488df139e71beec2565c146073381e7a20235900c037ec88bc6870/nodejs/node/issues/62653
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/55051d812b488df139e71beec2565c146073381e7a20235900c037ec88bc6870/nodejs/node/issues/62653
og:image:altVersion v24.14.1 (also affects v25.9.0) Platform Windows 11 Pro 10.0.26200 What steps will reproduce the bug? import fs from 'node:fs'; import path from 'node:path'; import os from 'node:os'; const...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameshulaoda
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/62653#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62653
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62653
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/62653
Reloadhttps://github.com/nodejs/node/issues/62653
Reloadhttps://github.com/nodejs/node/issues/62653
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62653
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62653
#62654https://github.com/nodejs/node/pull/62654
fs.cp creates file symlink instead of directory symlink on Windows when filter is providedhttps://github.com/nodejs/node/issues/62653#top
#62654https://github.com/nodejs/node/pull/62654
windowsIssues and PRs related to the Windows platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22windows%22
https://github.com/shulaoda
shulaodahttps://github.com/shulaoda
on Apr 9, 2026https://github.com/nodejs/node/issues/62653#issue-4233541029
test(glob-import): add follow symlinks test vitejs/vite#22196 (comment)https://github.com/vitejs/vite/pull/22196#discussion_r3056981191
https://github.com/damianremington274-blip
damianremington274-bliphttps://github.com/damianremington274-blip
on Apr 9, 2026https://github.com/nodejs/node/issues/62653#issuecomment-4216327996
juanarbolhttps://github.com/juanarbol
windowsIssues and PRs related to the Windows platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22windows%22
on Apr 9, 2026https://github.com/nodejs/node/issues/62653#event-24348467472
shulaodahttps://github.com/shulaoda
on Jun 25, 2026https://github.com/nodejs/node/issues/62653#event-27224345349
fs: pass symlink type in cp when filter is providedhttps://github.com/shulaoda/node/commit/793de4286379f6346a39e567b0dff2853c20b559
793de42https://github.com/shulaoda/node/commit/793de4286379f6346a39e567b0dff2853c20b559
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Jul 20, 2026https://github.com/nodejs/node/issues/62653#issuecomment-5019604137
GitHub Actionshttps://help.github.com/en/actions
github-actionshttps://github.com/apps/github-actions
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
on Jul 20, 2026https://github.com/nodejs/node/issues/62653#event-28198462391
https://github.com/shulaoda
shulaodahttps://github.com/shulaoda
on Jul 20, 2026https://github.com/nodejs/node/issues/62653#issuecomment-5019716797
github-actionshttps://github.com/apps/github-actions
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22stale%22
on Jul 21, 2026https://github.com/nodejs/node/issues/62653#event-28243801134
nodejs-github-bothttps://github.com/nodejs-github-bot
on Aug 22, 2026https://github.com/nodejs/node/issues/62653#event-29853578629
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/7d69ed11f7e1d7732ee3a6ef20f1e5152177927e
7d69ed1https://github.com/nodejs/node/commit/7d69ed11f7e1d7732ee3a6ef20f1e5152177927e
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#62654https://github.com/nodejs/node/pull/62654
on Aug 22, 2026https://github.com/nodejs/node/issues/62653#event-29853578644
aduh95https://github.com/aduh95
on Aug 25, 2026https://github.com/nodejs/node/issues/62653#event-30010189815
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/3246087cce923e25c18b086e023e92e0ad5f8121
3246087https://github.com/nodejs/node/commit/3246087cce923e25c18b086e023e92e0ad5f8121
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/6305a744df59fe53d50f8df4d2e1a5c70bcb60ac
6305a74https://github.com/nodejs/node/commit/6305a744df59fe53d50f8df4d2e1a5c70bcb60ac
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/adabc085e65e0cd0caa207153ef8a90afa4f9a84
adabc08https://github.com/nodejs/node/commit/adabc085e65e0cd0caa207153ef8a90afa4f9a84
aduh95https://github.com/aduh95
on Sep 7, 2026https://github.com/nodejs/node/issues/62653#event-30681670589
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/e5ed96a2608fcd295d1fa8b5e718ba4fbc3bc760
e5ed96ahttps://github.com/nodejs/node/commit/e5ed96a2608fcd295d1fa8b5e718ba4fbc3bc760
fs: pass symlink type in cp when filter is providedhttps://github.com/nodejs/node/commit/bc54dd89051973fc0d9243b07dcf86c62803b517
bc54dd8https://github.com/nodejs/node/commit/bc54dd89051973fc0d9243b07dcf86c62803b517
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/62653
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62653
windowsIssues and PRs related to the Windows platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22windows%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.