Re: [w3c/FileAPI] Why are Blob() and File() constructors at Chromium 81 throwing RangeError? (#147)

> A quick glance at your code in the crbug - are you accidentally passing an array of arrays in to the constructor, rather than just an array? That might be triggering an implicit string conversion in the bindings code.

Your observation appears to be correct for `Blob()`, where an `Array` of `Promise`s is passed to 

```
const arr = [];
function  doStuff() {
   arr.push(new Promise(resolve =>  resolve('value')))
}
Promise.all(arr).then(result => {
  let blob, file;
  try {
    blob = new Blob(result); // without `[]` which File requires `[]` within constructor
      console.log({blob}); // blob is logged
    } catch (e) {
      console.error(e);
    }
})
```

Initially loaded plnkr with refresh automatically enabled, to rule out that being the case for `Promise.all()` not settling, tried again, and the result, with `Array` containing `ArrayBuffer`s, not `Uint8Array`s, using `File` is that the `{file}` is not logged at all

```
const arr = [];
function  doStuff() {
   arr.push(new Promise(resolve =>  resolve('value')))
}
// never settled?
Promise.all(arr).then(result => {
  let blob, file;
  try {
   // never logged
    file = new File([result]); // File requires `[]` within constructor
      console.log({file}); // file is not logged
    } catch (e) {
      console.error(e);
    }
})
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/FileAPI/issues/147#issuecomment-602290223

Received on Sunday, 22 March 2020 23:00:04 UTC