Open Plumbiu opened 8 months ago
I can't reproduce on macOS.
Reproducible on Windows.
import fsp from 'node:fs/promises'
try {
await fsp
.readdir('中文-にほんご-한글-🌕🌖🌗', {
withFileTypes: true,
encoding: 'utf-16le',
})
.catch((error) => {
console.log('.catch', error)
})
} catch (error) {
console.log('try catch')
}
It does catch some error but not the expected one.
node index.mjs
.catch TypeError: Cannot destructure property '0' of 'undefined' as it is undefined.
at getDirents (node:internal/fs/utils:249:32)
at node:internal/util:442:7
at new Promise (<anonymous>)
at getDirents (node:internal/util:428:12)
at Object.readdir (node:internal/fs/promises:864:5)
at async file:///<redact>/index.mjs:4:3
node:internal/fs/promises:857
const result = await binding.readdir(
^
Error: ENOENT: no such file or directory, scandir
at Object.readdir (node:internal/fs/promises:857:32)
at file:///<redact>/index.mjs:5:6
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12) {
errno: -4058,
code: 'ENOENT',
syscall: 'scandir'
}
Node.js v20.10.0
It can be reproduced on my Windows from v20.4.0. as mentioned in https://github.com/nodejs/node/issues/48673#issuecomment-1624340450, that maybe because that libuv introduced WTF-8. and as mentioned in https://github.com/nodejs/node/issues/48673#issuecomment-1865958389 , it has been fixed since v21.5.0
This breaking regression bug is still not fixed in 20.x "LTS" while it was fixed in "Current" 21.x in December, 2 months ago.
I noted it in multiple issues and PRs.
Version
v20.10.0
Platform
Microsoft Windows NT 10.0.22621.0 x64
Subsystem
node:internal/fs/promises
What steps will reproduce the bug?
run code:
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
No Error in terminal
What do you see instead?
Error in terminal:
Additional information
No response