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

[win][fs] support of filename with surrogate pairs is lost in the latest releases #49998

Closed
AlttiRi opened this issue Oct 1, 2023 · 2 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@AlttiRi
Copy link

AlttiRi commented Oct 1, 2023

Version

v20.8.0
v18.18.0

Platform

Windows 10

Subsystem

fs

What steps will reproduce the bug?

Try to run it:

import fs from "node:fs/promises";


const filename = "file - テキスト - 🟦.txt";
await fs.writeFile(filename, filename);

// node:internal/fs/promises:590
//     await binding.openFileHandle(pathModule.toNamespacedPath(path),
//                   ^
//
// Error: ENOENT: no such file or directory, open

Then create file - テキスト - 🟦.txt and try to run these:

import fs from "node:fs/promises";

const filename = "file - テキスト - 🟦.txt";

console.log(await fs.lstat(filename));
// node:internal/fs/utils:554
//     stats[0 + offset], stats[1 + offset], stats[2 + offset],
//          ^
//
// TypeError: Cannot read properties of undefined (reading '0')
import fs from "node:fs/promises";

const filename = "file - テキスト - 🟦.txt";


function exists(path, followSymbol = true) {
    return (followSymbol ? fs.stat(path) : fs.lstat(path))
        .then(stats => true)
        .catch(error => false);
}

await exists(filename);
// node:internal/fs/promises:894
//   const result = await binding.stat(pathModule.toNamespacedPath(path),
//                                ^
//
// Error: ENOENT: no such file or directory, stat

How often does it reproduce? Is there a required condition?

Always with Node.js v20.8.0 and v18.18.0 only.

What is the expected behavior? Why is that the expected behavior?

It should work the same way as with Node.js 18.17.1.

What do you see instead?

Errors.

Additional information

I just updated my Node.js from 18.17.1 LTS to 20.8.0 Current and now my file scanner no more works.

@AlttiRi
Copy link
Author

AlttiRi commented Oct 1, 2023

The latest LTS 18.18.0 also contains this critical bug.
18.17.1 works OK.

@AlttiRi AlttiRi changed the title [win][fs] support of filename with surrogate pairs is lost in the latesr release [win][fs] support of filename with surrogate pairs is lost in the latest releases Oct 1, 2023
@bnoordhuis
Copy link
Member

Known issue, duplicate of #48673. A fix is pending release.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2023
@bnoordhuis bnoordhuis added duplicate Issues and PRs that are duplicates of other issues or PRs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform. labels Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

2 participants