Skip to content

Conversation

@y-okt
Copy link
Contributor

@y-okt y-okt commented Dec 2, 2025

Fixes: #58892

Calling readdir with a Buffer argument and the recursive flag produces an ERR_INVALID_ARG_TYPE error. The expected behavior would be for the readdir functions not to error and return either an array of Buffers or Dirents (depending on options.withFileTypes)

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 96.61017% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.54%. Comparing base (4f24aff) to head (909880c).

Files with missing lines Patch % Lines
lib/internal/fs/promises.js 93.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60936      +/-   ##
==========================================
+ Coverage   88.53%   88.54%   +0.01%     
==========================================
  Files         703      703              
  Lines      208546   208596      +50     
  Branches    40217    40238      +21     
==========================================
+ Hits       184634   184701      +67     
+ Misses      15926    15905      -21     
- Partials     7986     7990       +4     
Files with missing lines Coverage Δ
lib/fs.js 98.20% <100.00%> (+0.01%) ⬆️
lib/internal/fs/promises.js 98.03% <93.10%> (-0.12%) ⬇️

... and 38 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mohataseem89
Copy link
Contributor

correct handling of buffer arguments in recursive readdir aligns the behavior with people's expectations and makes the fs API more consistent

the Codecov report shows two uncovered lines in promises.js - adding a test for the recursive + Buffer path would close that gap and make the fix fully covered

y-okt added a commit to y-okt/node that referenced this pull request Dec 8, 2025
add a test with withFileTypes true

Fixes: nodejs#60936
@y-okt y-okt force-pushed the fix-readdir-recursive branch from 738b7ed to 36b64a5 Compare December 9, 2025 12:39
y-okt added a commit to y-okt/node that referenced this pull request Dec 9, 2025
add a test with withFileTypes true

Fixes: nodejs#60936
calling readdir with a buffer arguemnt and the recursive flag
produces an ERR_INVALID_ARG_TYPE error. This is to fix that.

Fixes: nodejs#58892
add a test with withFileTypes true

Fixes: nodejs#60936
fix failing tests in the previous commit

Fixes: nodejs#60936
@y-okt y-okt force-pushed the fix-readdir-recursive branch from 36b64a5 to 923d4f4 Compare December 13, 2025 12:37
as CI is failing, make test fix

Fixes: nodejs#60936
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all versions of readdir don't work in recursive mode when used with a buffer argument

3 participants