Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node on Windows can't access filenames containg emojis #49042

Closed
dandrei opened this issue Aug 6, 2023 · 1 comment
Closed

Node on Windows can't access filenames containg emojis #49042

dandrei opened this issue Aug 6, 2023 · 1 comment

Comments

@dandrei
Copy link

dandrei commented Aug 6, 2023

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.

@bnoordhuis
Copy link
Member

I think this is a duplicate of #48673 which has been fixed but not released yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants