You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.opendir() and fs.promises.opendir() crash the process on an invalid bufferSize #67182
How often does it reproduce? Is there a required condition?
Always, with any invalid bufferSize (0, -1, 1.5, NaN, '1', null, ...).
What is the expected behavior? Why is that the expected behavior?
The error reaches the caller: fs.opendir() throws (as fs.readdir() and fs.writeFile() do for invalid options), and fs.promises.opendir() rejects. fs.opendirSync() already throws a catchable error.
What do you see instead?
Neither catch runs, the callback is never called, and the process exits with code 1:
RangeError [ERR_OUT_OF_RANGE]: The value of "options.bufferSize" is out of range. It must be >= 1 && <= 4294967295. Received 0
at new Dir (node:internal/fs/dir:64:7)
at FSReqCallback.opendirCallback [as oncomplete] (node:internal/fs/dir:357:22)
Additional information
bufferSize is only validated in the Dir constructor, which fs.opendir() calls from the completion callback of the native call, so the error is thrown outside the caller's code. The handle is closed before the throw, so nothing leaks. I have a fix and will open a PR.
Activity