PapaParse
PapaParse copied to clipboard
Worker: true error Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
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
@pokoli any suggestions? Would love to be able to use webWorkers for this heavy loading :)
IIRC combining download and workers is not supported. So this is something that should be improved on the library
There are tests (e.g. "Step exposes cursor for workers") that combine download and worker so the feature at least seems to be supported.
I'm experiencing the same error, @toddmedema how did you fix/workaround it?
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.