deno
728239f3 - fix(ext/node): drop extra positional args in promisified fs.promises.* (#34347)

Commit
66 days ago
fix(ext/node): drop extra positional args in promisified fs.promises.* (#34347) `Array#map` invokes `fn(elem, index, array)`, so the idiomatic `paths.map(fs.promises.unlink)` ends up calling the promisify wrapper with three positionals. The wrapper appends its own callback, producing `fs.unlink(path, index, array, cb)`; callback-style `fs.unlink` then validates the second positional as the callback and rejects with `TypeError: The "callback" argument must be of type function. Received type number (0)`. The same shape affected every `fs.promises.*` method built via `util.promisify` (`rename`, `rm`, `chmod`, `stat`, `readFile`, ...). `lazyPromisifyFs` now takes the underlying method's positional arity and slices incoming args to that length before delegating, matching Node, whose own `fs.promises.*` wrappers don't go through `util.promisify` and so don't have this issue. Fixes #34335
Author
Parents
Loading