Skip to content

Commit 6a4c236

Browse files
committed
fs: always return promise from openAsBlob()
Wrap path validation and blob creation in try/catch. Any synchronous errors become Promise rejections. Ensures the function always returns a Promise. Fixes: #62418
1 parent e6ef477 commit 6a4c236

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/fs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,12 @@ function openAsBlob(path, options = kEmptyObject) {
574574
// The underlying implementation here returns the Blob synchronously for now.
575575
// To give ourselves flexibility to maybe return the Blob asynchronously,
576576
// this API returns a Promise.
577-
path = getValidatedPath(path);
578-
return PromiseResolve(createBlobFromFilePath(path, { type }));
577+
try {
578+
path = getValidatedPath(path);
579+
return PromiseResolve(createBlobFromFilePath(path, { type }));
580+
} catch (error) {
581+
return Promise.reject(error);
582+
}
579583
}
580584

581585
/**

0 commit comments

Comments
 (0)