René's URL Explorer Experiment


Title: readdir(p, { withFileTypes: true }) seemingly returns wrong type · Issue #30646 · nodejs/node · GitHub

Open Graph Title: readdir(p, { withFileTypes: true }) seemingly returns wrong type · Issue #30646 · nodejs/node

X Title: readdir(p, { withFileTypes: true }) seemingly returns wrong type · Issue #30646 · nodejs/node

Description: Version: v13.1.0 Platform: Darwin White-Star.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64 Subsystem: fs When listing a directory with readdir and withFileTypes, at ...

Open Graph Description: Version: v13.1.0 Platform: Darwin White-Star.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64 Subsystem: fs When listing a direc...

X Description: Version: v13.1.0 Platform: Darwin White-Star.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64 Subsystem: fs When listing a direc...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"readdir(p, { withFileTypes: true }) seemingly returns wrong type","articleBody":"\u003c!--\r\nThank you for reporting a possible bug in Node.js.\r\n\r\nPlease fill in as much of the template below as you can.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify the affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you can.\r\n-->\r\n\r\n* **Version**: v13.1.0\r\n* **Platform**: Darwin White-Star.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64\r\n* **Subsystem**: fs\r\n\r\n\u003c!-- Please provide more details below this comment. -->\r\n\r\nWhen listing a directory with `readdir` and `withFileTypes`, at least the promisified version of `fs.readdir` returns the wrong type for entities that are symbolic links to directories:\r\n\r\n```javascript\r\nconst { basename, join } = require('path');\r\nconst { readdir, lstat, stat, symlink, unlink } = require('fs').promises;\r\nconst LINK_NAME = basename(__filename) + '-link';\r\nconst LINK_PATH = join(__dirname, LINK_NAME);\r\n\r\nconst inspectEntity = (label, entity) => {\r\n  console.log(label, (entity.isDirectory() ? 'dir' : '') +\r\n    (entity.isFile() ? 'file' : '') +\r\n    (entity.isSymbolicLink() ? 'symlink' : ''));\r\n};\r\n\r\n(async function main() {\r\n  try {\r\n    await symlink(__dirname, LINK_PATH, 'dir');\r\n\r\n    for (const entity of await readdir(__dirname, { withFileTypes: true })) {\r\n      if (entity.name === LINK_NAME) inspectEntity('readdir', entity);\r\n    }\r\n    inspectEntity('lstat', await lstat(LINK_PATH));\r\n    inspectEntity('stat', await stat(LINK_PATH));\r\n\r\n    await unlink(LINK_PATH);\r\n  } catch (x) {\r\n    console.error(x.stack);\r\n  }\r\n})();\r\n```\r\n\r\nRunning the above script yields the following on my machine:\r\n```\r\nreaddir file\r\nlstat symlink\r\nstat dir\r\n```\r\n\r\nSince the file system entity in question is a symbolic link to a directory, I would expect the code to either report a symlink or a directory, depending on whether the implementation of `readdir` uses `stat` or `lstat` under the covers. But in *neither* case would I expect a file to be reported. Yet that's exactly what's happening on my machine. Am I missing something or is this a genuine bug?\r\n\r\nAdditional testing with a second machine suggests that this may be related to **remote file system** usage. When running the test locally on a local disk, `readdir` reports a symlink (yay!). That stands in contrast to my original testing was performed on a remotely mounted file system.\r\n\r\nAs an aside, after reading a number of old issues before filing this issue, I am guessing that `readdir` uses `stat` not `lstat` under the covers. It would seem more consistent with the rest of the API. Yet the documentation has no disclaimer on `dirent.isSymbolicLink()` as it has on `stats.isSymbolicLink()`. Either way, being more upfront about `readdir`'s behavior `{withFileTypes: true}` would go a long way towards a better developer experience. I'm happy to submit a PR for that—once I understand what's going on above.\r\n\r\nEven with better documentation though, some developers will be disappointed when whatever `readdir` uses does not meet their use case. So I am also wondering whether configurability of `stat`/`lstat` for `readdir` `withFileTypes: true` would be desirable in the long term. If that suggestion falls under the heading \"long-term costs of exposing things from core,\" I apologize. I'm gonna practice writing code *without* using `withFileTypes` for certain tonight. 😜","author":{"url":"https://github.com/apparebit","@type":"Person","name":"apparebit"},"datePublished":"2019-11-25T23:41:35Z","url":"https://github.com/nodejs/node/issues/30646"}

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:43d10387-984d-4efb-9cd7-2ac4df48f7b0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEDAA:2B6F5F:2CDC9AB:3F329A0:6AED2C9C
html-safe-nonce38767fc7841b88b788b35387eeca00db9061c662d344abcac54fdcdd06fdd1cd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREFBOjJCNkY1RjoyQ0RDOUFCOjNGMzI5QTA6NkFFRDJDOUMiLCJ2aXNpdG9yX2lkIjoiOTE0OTgzOTI5MDg0ODMyNDc2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac49ca3314dfbe8c7779447c0f69af3e6caa36eacc35fbf65261f97436fbf58192
hovercard-subject-tagissue:528401439
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/30646/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ff497f30828f5d395c3f3ba81ea1ca7044941117dfa01408fbb424a15ce752df/nodejs/node/issues/30646
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ff497f30828f5d395c3f3ba81ea1ca7044941117dfa01408fbb424a15ce752df/nodejs/node/issues/30646
og:image:altVersion: v13.1.0 Platform: Darwin White-Star.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64 Subsystem: fs When listing a direc...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameapparebit
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
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
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/30646#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F30646
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%2F30646
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/30646
Reloadhttps://github.com/nodejs/node/issues/30646
Reloadhttps://github.com/nodejs/node/issues/30646
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/30646
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/30646
#64532https://github.com/nodejs/node/pull/64532
readdir(p, { withFileTypes: true }) seemingly returns wrong typehttps://github.com/nodejs/node/issues/30646#top
#64532https://github.com/nodejs/node/pull/64532
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
macosIssues and PRs related to the macOS platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22macos%22
https://github.com/apparebit
apparebithttps://github.com/apparebit
on Nov 25, 2019https://github.com/nodejs/node/issues/30646#issue-528401439
addaleaxhttps://github.com/addaleax
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
macosIssues and PRs related to the macOS platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22macos%22
on Nov 28, 2019https://github.com/nodejs/node/issues/30646#event-2837312778
https://github.com/addaleax
addaleaxhttps://github.com/addaleax
on Nov 28, 2019https://github.com/nodejs/node/issues/30646#issuecomment-559293042
@apparebithttps://github.com/apparebit
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Jun 27, 2026https://github.com/nodejs/node/issues/30646#issuecomment-4820316825
GitHub Actionshttps://help.github.com/en/actions
https://github.com/soreavis
soreavishttps://github.com/soreavis
on Jul 16, 2026https://github.com/nodejs/node/issues/30646#issuecomment-4992656233
#64532https://github.com/nodejs/node/pull/64532
@addaleaxhttps://github.com/addaleax
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/30646
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/30646
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
macosIssues and PRs related to the macOS platform.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22macos%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.