Skip to content

Emoji in path breaks on windows using fs.readFile #49947

@nicojs

Description

@nicojs

Version

18.18.0

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

No response

What steps will reproduce the bug?

import fs from "fs";

try {
  await fs.promises.open("./😋");
} catch (e) {
  console.log("Custom error log", e);
}

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

Always on windows. Works as expected on Node 18.17.1, but not on Node 18.18.

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

Custom error log [Error: ENOENT: no such file or directory, open './😋'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: './😋'
}

What do you see instead?

node:internal/fs/promises:590
    await binding.openFileHandle(pathModule.toNamespacedPath(path),
                  ^

Error: ENOENT: no such file or directory, open
    at Object.open (node:internal/fs/promises:590:19)
    at file:///C:/users/nicoj/github/tmp/index.js:4:21
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open'
}

Additional information

Note: also when the file exists in disk it crashes on Windows with the same error. Node 18.18.0 on linux works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions