-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Description
Version
v20.5.0
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
fs
What steps will reproduce the bug?
Create an empty directory and have two files there:
TEST 🤖.txt
test.js
, with the following content:
const path = require("path")
const fs = require("fs");
const {promisify} = require("util");
const access = promisify(fs.access)
const readdir = promisify(fs.readdir)
async function file_exists(f) {
try {
await access(f)
return true;
} catch (e) {
console.error(e);
return false;
}
}
async function test() {
for (const f of await readdir('.')) {
console.log(f, await file_exists(f));
}
}
test().then()
How often does it reproduce? Is there a required condition?
It happens whenever trying to access a filename contains emoji characters.
What is the expected behavior? Why is that the expected behavior?
All node functions should be able to access these files, especially since readdir
correctly lists them, including those containg emojis.
What do you see instead?
The output on Windows is (I've anonymized local system file paths):
Error: ENOENT: no such file or directory, access
at access (node:fs:236:11)
at node:internal/util:411:7
at new Promise (<anonymous>)
at access (node:internal/util:397:12)
at file_exists (test.js:9:15)
at test (test.js:19:30) {
errno: -4058,
code: 'ENOENT',
syscall: 'access'
}
TEST 🤖.txt false
test.js true
On Linux and node v16.14.2 it outputs correctly (the output of file_exists
is true
):
TEST 🤖.txt true
test.js true
Additional information
Affected functions are, at least:
access
stat
readFile
Even though readdir
lists filenames containg emojis, the functions used to access the files individually throw an ENOENT
error.
syuilo and AlttiRi
Metadata
Metadata
Assignees
Labels
No labels