Skip to content

fs.promises.mkdtemp has internal error under --permissions #58747

Description

@bakkot

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    permissionIssues and PRs related to the Permission Model.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions