PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

Worker: true error Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

Open toddmedema opened this issue 5 years ago • 5 comments

Full error:

Uncaught DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
    at l._readChunk (blob:http://localhost:8080/0b8053c6-ba21-4708-8fbe-cf0ee7c7f2ed:1:7241)
    at l._nextChunk (blob:http://localhost:8080/0b8053c6-ba21-4708-8fbe-cf0ee7c7f2ed:1:6870)
    at l.stream (blob:http://localhost:8080/0b8053c6-ba21-4708-8fbe-cf0ee7c7f2ed:1:6977)
    at Object.parse (blob:http://localhost:8080/0b8053c6-ba21-4708-8fbe-cf0ee7c7f2ed:1:1097)
    at f.onmessage (blob:http://localhost:8080/0b8053c6-ba21-4708-8fbe-cf0ee7c7f2ed:1:18176)

The code - which works fine when I don't include worker: true:

function downloadWeather(location: string) {
  weather[location] = [];
  let rowNumber = 0;
  Papa.parse(`/data/WeatherRaw${location}.csv`, {
    download: true,
    dynamicTyping: true,
    header: true,
    worker: true,
    step(row: any) {
      weather[location].push(row.data as RawWeatherType);
    },
    complete() {
      console.log('Weather downloaded for ' + location);
    },
  });
}

The only two things I can think of are a bug in the library (unlikely), or that I need to set up something special in webpack to work with webworkers? Here's my webpack file: https://github.com/toddmedema/electrify/blob/master/shared/webpack.shared.js

toddmedema avatar Dec 17 '19 05:12 toddmedema

@pokoli any suggestions? Would love to be able to use webWorkers for this heavy loading :)

toddmedema avatar Jan 24 '20 04:01 toddmedema

IIRC combining download and workers is not supported. So this is something that should be improved on the library

pokoli avatar Jan 24 '20 14:01 pokoli

There are tests (e.g. "Step exposes cursor for workers") that combine download and worker so the feature at least seems to be supported.

demetris-manikas avatar May 07 '20 12:05 demetris-manikas

I'm experiencing the same error, @toddmedema how did you fix/workaround it?

travis-south avatar Jul 29 '21 02:07 travis-south

since download and workers don't work together, I opted for using the fetch api like this:

const data = await fetch(csvPath)
const blob = await data.blob();

Papa.parse(blob, {
   worker: true,
   ...
})

Don't know if this is a good solution, but hope it helps someone.

Jake-Prentice avatar Dec 03 '21 19:12 Jake-Prentice