The issue clearly describes a bug where `openAsBlob` fails synchronously instead of returning a rejected promise.
The issue reports that `openAsBlob` fails synchronously rather than returning a rejected promise as expected. The fix involves ensuring the function properly returns a promise in all cases. The maintainer feedback suggests this is a known inconsistency in the API design.
v24.14.0
Linux vali 6.18.7-76061807-generic #202601231045~1769703228~24.04~cb87b5b SMP PREEMPT_DYNAMIC Thu J x86_64 x86_64 x86_64 GNU/Linux
fs
import { openAsBlob } from 'node:fs'
const result = await openAsBlob('does-not-exist').catch((error) => {})
console.log(result)
Always
I expect openAsBlob() to always return a promise. If there are any problems, I expect the promise to be rejected.
Instead of returning a promise that’s rejected, openAsBlob() fails synchronously. This means that instead of using the Promise.catch() method, you have to use try/catch logic instead.
Just marking the function as async on https://github.com/nodejs/node/blob/v25.8.1/lib/fs.js#L570 would fix it.
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!