mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.44k stars 1.14k forks source link

React Native issue Synchronous http requests are not supported #507

Closed apellizzn closed 6 years ago

apellizzn commented 6 years ago

Hi, I don't know if this library is intended to work also with React Native, in that case just want to report this issue, the following code

 Papa.parse(url, {
      download: true,
      delimiter: ';',
      trimHeader: true,
      header: true,
      skipEmptyLines: true,
      complete: ({ data }) => console.log(data),
    }));

raises Error: Synchronous http requests are not supported Debugging this lead to paraparse.js:590 xhr.open('GET', this._input, !IS_WORKER);

where !IS_WORKER is always true, setting IS_WORKER = false at paraparse.js:45 just make it works fine.

EDIT: Actually this happens only when the React Native Debugger is running seems related to the fact that postMessage function is being add to global

rendomnet commented 4 years ago

@apellizzn What use suggest? how to fix this problem and use debugger?

apellizzn commented 4 years ago

@rendomnet From what I remember I've just opened the node module and hardcoded IS_WORKER = false in my local since this fix was needed only for debugging pourpose

rendomnet commented 4 years ago

@apellizzn this seems to be not working now. :( papaparse": "5.2.0"

    // var IS_WORKER = !global.document && !!global.postMessage,
    //  IS_PAPA_WORKER = IS_WORKER && /blob:/i.test((global.location || {}).protocol);
    var IS_WORKER = false;
    var IS_PAPA_WORKER = false;