You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.globSync returns incorrect results with non-UTF8 encoded file names. #59202
For example... on Linux, where file names are just byte sequences...
const{ writeFileSync, existsSync, globSync }=require('node:fs');constpath=Buffer.from([0xe9]);writeFileSync(path,'hello');existsSync(path);// trueconsole.log(globSync('[^a-z]'));// [ '�' ] non-utf8 bytes in the file name end up replaced.
The globSync, et. al APIs likely need an encoding option that instructs it to return the filenames as Buffer objects.
Activity
targos commentedon Jul 25, 2025
Is it specific to
globSync? What about other async variants? Andreaddir?jasnell commentedon Jul 25, 2025
All of the glob* APIs. Similar
readdirissues are reported in #58892There quite a few fs APIs impacted by similar issues.
silverwind commentedon Oct 7, 2025
I too noticed that the
glob*APIs are lacking anencodingoption likereaddirhas, making it impossible to read utf8-invalid filenames with them.Of note is that
withFileTypesoption is specified, the resultingfs.Dirents should also useencodingin theirnameattribute.fs: support encoding option in glob