Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using transformHeader with header: true and worker: true #761

Open
bleuf1sh opened this issue Jan 30, 2020 · 9 comments
Open

Error using transformHeader with header: true and worker: true #761

bleuf1sh opened this issue Jan 30, 2020 · 9 comments

Comments

@bleuf1sh
Copy link

The error was about not being able to clone in postMessage.

I was working with a remote csv in a Chrome Web Front End.

@pokoli
Copy link
Collaborator

pokoli commented Jan 30, 2020

could you post the full tracebak?

@bleuf1sh
Copy link
Author

I've provided the example function as well and removed private details.

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Worker': (h) => {
                    return h.trim();
                } could not be cloned.
    at Object.parse (chrome-extension://asfdasdf/background/background.js:35623:967)
    at chrome-extension://asfdasdf/background/background.js:46081:18
    at new Promise (<anonymous>)
    at Function.loadCsvRules (chrome-extension://asfdasdf/background/background.js:46079:16)

private static async loadCsvRules(csvUrl: string): Promise<any[]> {
    return new Promise( (resolve, reject) => {
      const datas = [];
      Papa.parse(csvUrl, {
        download: true,
        header: true,
        worker: true,
        transformHeader: (h) => {
          return h.trim();
        },
        step: (row) => {
          datas.push(row.data);
        },
        complete: () => {
          resolve(datas);
        }
      });
    });
  }

@abodnar
Copy link

abodnar commented Feb 14, 2020

I'm having this same problem as well. Any suggestions on how to resolve this?

@steveryan
Copy link

Having the same issue over here. Would love to find a workaround for this.

@ux-engineer
Copy link

Same here...

@jchan18
Copy link

jchan18 commented Oct 7, 2020

Is there any update with this issue? I'm seeing this problem too

@mikeappell
Copy link

mikeappell commented Jul 15, 2021

👍 on this, it seems like transformHeader is incompatible with worker: true which really stinks. Even
transformHeader: header => header
seems like it fails; assuming the function is being passed to the worker and simply cannot be serialized.

Might at least want to update the documentation to reflect this; did not see it referenced.

Just so as not to poo all over an amazing project: PapaParse is really excellent and has proven utterly invaluable, so thanks for such an awesome tool 🎊

@jaymathew
Copy link

I'm a new PapaParse user, and I wish this were fixed or documented. It would have saved me some time. The last message was over a year ago, and I hate to beat a dead horse, but is there any update on this issue?

imReker added a commit to imReker/PapaParse that referenced this issue Sep 5, 2022
When worker set to true, convert transformHeader function to string, so the config could be cloned to worker and convert back in worker thread by `eval`.
So, when using Content Security Policy, this workaround will still fail, consider to use vkThread instead.
@joaquinricci
Copy link

joaquinricci commented Mar 10, 2023

Same thing happen to me but with transform and not transformHeader, it seems that the error is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants