-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Hello!
We're using elm/file in our project to upload files from the user's computer.
In some cases, we've had a runtime error:
It's hard to explain how to reproduce the case, because for us it concerns files synchronized with One Drive. When the One Drive application is not launched, we can't open some files (for example with the Excel desktop app).
SSCCE
https://ellie-app.com/8Nkyf2KYWPSa1 (but I don't know how to reproduce the proper "state" for the file to upload)
Cause
The problem is in this file:
function _File_toString(blob)
{
return __Scheduler_binding(function(callback)
{
var reader = new FileReader();
reader.addEventListener('loadend', function() {
callback(__Scheduler_succeed(reader.result));
});
reader.readAsText(blob);
return function() { reader.abort(); };
});
}We're assuming that the loadend event means that everything was successful, but the documentation says that it is also called if the read operation fails. So we need to check before wrapping it in a succeed (here, the reader.result value is null) or maybe listen to load instead.
The problem should be the same with File.toUrl and File.toBytes.
