Closed Amatewasu closed 2 years ago
I think a timeout would be the most logical. You can do this without any changes actually:
Promise.race([
directoryOpen({ recursive: true }),
sleep(2000),
]);
Great idea, thank you!
I identify two problems with Promise.race
.
directoryOpen
promise that still runs in the background, it could be quite resource-intensive if the user selected a large folderPromise.race
will resolve/reject after the sleep duration if the user takes a while to select the folder
- it does not resolve/reject the
directoryOpen
promise that still runs in the background, it could be quite resource-intensive if the user selected a large folder
You could maybe make this work by leveraging the legacySetup
parameter.
- it includes the elapsed time for the user to select the folder, thereby
Promise.race
will resolve/reject after the sleep duration if the user takes a while to select the folder
That's true. I don't think there is a workaround unfortunately.
When calling the function
directoryOpen({ recursive: true })
and the user selects a large folder (such as C:\ for Windows users for example), it will try to load too many files and the promise will not resolve.It would be great to add the ability to abort. I don't know what could be exactly the best parameters to add, but I can think of: