Open
Description
Version
v24.2.0
Platform
Darwin The-Box.local 23.6.0 Darwin Kernel Version 23.6.0: Fri Nov 15 15:11:49 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6020 arm64
Subsystem
fs
What steps will reproduce the bug?
Run node --permission
(granting no permissions), then
await fs.promises.mkdtemp('asdf')
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
This should throw a single ERR_ACCESS_DENIED
error.
What do you see instead?
This produces the wrong error:
TypeError: Method Promise.prototype.then called on incompatible receiver undefined
at then (<anonymous>)
at Object.mkdtemp (node:internal/fs/promises:1178:16)
at REPL65:1:51
and also produces an uncaught error with the right error:
Error: Access to this API has been restricted. Use --allow-fs-write to manage permissions.
at Object.mkdtemp (node:internal/fs/promises:1179:13)
at REPL65:1:51 {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: 'asdfXXXXXX'
Additional information
You can also wrap it in a try-catch and observe that there is still an uncaught error, which should never happen:
> try { await fs.promises.mkdtemp('asdf') } catch {}
undefined
> Uncaught:
Error: Access to this API has been restricted. Use --allow-fs-write to manage permissions.
at Object.mkdtemp (node:internal/fs/promises:1179:13)
at REPL66:1:40 {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
resource: 'asdfXXXXXX'