alberthaff / ngx-papaparse

Papa Parse wrapper for Angular
https://alberthaff.dk/projects/ngx-papaparse/docs/v8
MIT License
90 stars 19 forks source link

Enabled serviceworkers, but page still freezes while CSV file is being parsed #99

Closed MaxBatt closed 1 year ago

MaxBatt commented 2 years ago

Describe the bug

When enabling serviceworkers by setting the according flag to true, the CSV data is correctly parsed, but the page UI completely freezes until parsing is finished. So, the behaviour is the same as wehen setting the workers flag to false.

To Reproduce

  1. Add the following to the "assets" array inside angular.json:
    {
    "glob": "**/papaparse.min.js",
    "input": "./node_modules/papaparse",
    "output": "/assets/"
    }
  2. Adding the folowing to the "providers" array inside the app.module.ts:
    {
    provide: 'PapaParseGlobalConfig',
    useValue: <PapaParseGlobalConfig>{
    scriptPath: '/assets/papaparse.min.js'
    }
    }
  3. Create a file object from existing blob and use the papa.parse method as follows:
    const csvData = new File([blob], fileName);
    this.papa.parse(csvData,
    {
      fastMode: true,
      worker: true,
      delimiter: ';',
      header: true,
      complete: (results, file) => {
        some post logic...
        ...  
      }
    }
    }
    );

Expected behavior

If the workers flag is set to true the page should stay reactive, while CSV data is parsed, as described in the docs:

Using a worker will keep your page reactive, but may be slightly slower. 
Note that worker option is only available when parsing files and not when converting from JSON to CSV. 

Software and platform

Additional context

Add any other context about the problem here.

alberthaff commented 2 years ago

Hi. Sorry for the late reply. Could you please check if the file is accessible on your site at (http://localhost:4200/assets/papaparse.min.js)?

If not, it might fallback to the default behaviour.