-
-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
Description
In the sync implementation, we make a statSync call, and if it fails, the original mkdirSync error is thrown:
Lines 137 to 143 in 9de6474
| try { | |
| if (!options.fs.statSync(pth).isDirectory()) { | |
| throw new Error('The path is not a directory'); | |
| } | |
| } catch (_) { | |
| throw error; | |
| } |
However, in the async implementation, we have no error handling for the stat call, and any failure there would bubble up:
Lines 84 to 87 in 9de6474
| const stats = await stat(pth); | |
| if (!stats.isDirectory()) { | |
| throw error; | |
| } |
In an earlier (pre-async/await) version, we properly swallowed any stat errors, and threw the original error, like the sync implementation:
Lines 76 to 80 in 379001f
| return stat(pth) | |
| .then(stats => stats.isDirectory() ? pth : Promise.reject()) | |
| .catch(() => { | |
| throw error; | |
| }); |
I don't have a test case to show if this actually creates an inconsistency for the end user, but it was just noticed in review, and I thought I'd report upstream.
Reactions are currently unavailable