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

[Bug]: fs.readdir does not work correctly with files that contain umlauts #42035

Open
3 tasks done
oliverschwendener opened this issue May 4, 2024 · 4 comments
Open
3 tasks done
Assignees
Labels
31-x-y bug 🪲 component/node-integration has-repro-repo Issue can be reproduced by cloning a git repo platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@oliverschwendener
Copy link

oliverschwendener commented May 4, 2024

Preflight Checklist

Electron Version

31.0.0-alpha.3

What operating system are you using?

Windows

Operating System Version

Windows 11

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

I'm trying to read files from a directory using node's fs.readdir function. When there is a file with umlauts in the name, for example äöü.txt it should return 'äöü.txt'.

Actual Behavior

When using fs.readdir in an electron application it returns 'äöü.txt'. Invoking the same code from node (v20.12.2) works as expected.

Testcase Gist URL

https://github.com/oliverschwendener/nodejs-readdir-test

Additional Information

The provided GitHub repo has a guide on how to reproduce the issue.

@codebytere
Copy link
Member

codebytere commented May 6, 2024

Can't reproduce this locally:

nodejs-readdir-test on git:main ❯ e node node.js                               1:50PM
Running "/Users/codebytere/Developer/electron-gn/src/out/Testing/Electron.app/Contents/MacOS/Electron node.js"
{ node: '20.12.2' }
[
  'äöü.txt'
]

@oliverschwendener
Copy link
Author

As far as I understand, it happens only on Windows.

@codebytere
Copy link
Member

codebytere commented May 6, 2024

@oliverschwendener you're right - my bad! reproduced on windows - will investigate further. Interestingly, this doesn't happen in the main process. Running:

const { readdir } = require("fs");
const { homedir } = require("os");
const { join } = require("path");

console.log({ node: process.versions.node });

readdir(join(homedir(), "Desktop"), (error, files) => {
    if (error) {
        console.error(`error: ${error}`);
    } else {
        console.log(files);
    }
});

in main.js correctly produces:

Saving files to temp directory...
Saved files to C:\Users\CODEBY~1\AppData\Local\Temp\electron-fiddle-9588-F6KBkUwJ7Ziu
Electron v999999999.9.9 started.

{ node: '20.12.2' }
[
'test.pdf',
'win_notif.patch',
'äöü.txt'
]

Electron exited with signal SIGTERM.

@codebytere codebytere added platform/windows component/node-integration status/confirmed A maintainer reproduced the bug or agreed with the feature labels May 6, 2024
@codebytere codebytere self-assigned this May 6, 2024
@oliverschwendener
Copy link
Author

oliverschwendener commented May 8, 2024

Interesting. With Electron Fiddle it works as expected, but when I run it with electron (in the main process) it does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
31-x-y bug 🪲 component/node-integration has-repro-repo Issue can be reproduced by cloning a git repo platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
Status: 👍 Does Not Block Stable
Development

No branches or pull requests

3 participants