Skip to content

fs: fix always return promise from fs.openAsBlob#62655

Draft
mattskel wants to merge 1 commit intonodejs:mainfrom
mattskel:fix-fs-api-promise-based-contract
Draft

fs: fix always return promise from fs.openAsBlob#62655
mattskel wants to merge 1 commit intonodejs:mainfrom
mattskel:fix-fs-api-promise-based-contract

Conversation

@mattskel
Copy link
Copy Markdown

@mattskel mattskel commented Apr 9, 2026

Summary: Ensure fs.openAsBlob always returns a Promise by converting synchronous validation/creation errors into Promise rejections so error handling is consistent.

Motivation: The issue reported that openAsBlob can throw synchronously (for invalid paths), which bypasses await/.catch. This aligns behaviour with the Promise-based API contract.

Changes: Wrap getValidatedPath and createBlobFromFilePath in try/catch and return Promise.reject on failure.

Fixes: #62418

Wrap path validation and blob creation
in try/catch. Any synchronous errors
become Promise rejections. Ensures the
function always returns a Promise.

Fixes: nodejs#62418
@mattskel mattskel marked this pull request as draft April 9, 2026 16:39
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openAsBlob fails synchronously

2 participants