Skip to content

Conversation

@sjwhole
Copy link

Previously, fs.promises.mkdtemp() would cause a TypeError "Method Promise.prototype.then called on incompatible receiver undefined" when called without write permissions. This happened because the promise was never returned to JavaScript after being rejected.

This commit ensures SetReturnValue() is called before returning from the function, so JavaScript receives a proper rejected promise with an ERR_ACCESS_DENIED error that can be caught and handled.

Fixes: #59023

Previously, fs.promises.mkdtemp() would cause a TypeError "Method Promise.prototype.then called on incompatible receiver undefined" when called without write permissions. This happened because the promise was never returned to JavaScript after being rejected. This commit ensures SetReturnValue() is called before returning from the function, so JavaScript receives a proper rejected promise with an ERR_ACCESS_DENIED error that can be caught and handled. Fixes: nodejs#59023
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/security-wg

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jul 13, 2025
@theanarkh
Copy link
Contributor

This bug affects many fs.promise APIs, Please See #58996.

@sjwholesjwhole closed this Aug 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.fsIssues and PRs related to the fs subsystem / file system.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in fs promise APIs

3 participants

@sjwhole@nodejs-github-bot@theanarkh