PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

Error using transformHeader with header: true and worker: true

Open bleuf1sh opened this issue 5 years ago • 9 comments

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

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

bleuf1sh avatar Jan 30 '20 06:01 bleuf1sh

could you post the full tracebak?

pokoli avatar Jan 30 '20 08:01 pokoli

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);
        }
      });
    });
  }

bleuf1sh avatar Jan 30 '20 16:01 bleuf1sh

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

abodnar avatar Feb 14 '20 15:02 abodnar

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

steveryan avatar Mar 31 '20 21:03 steveryan

Same here...

ux-engineer avatar Apr 02 '20 08:04 ux-engineer

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

jchan18 avatar Oct 07 '20 04:10 jchan18

👍 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 🎊

mikeappell avatar Jul 15 '21 17:07 mikeappell

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?

jaymathew avatar Sep 04 '22 03:09 jaymathew

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

joaquinricci avatar Mar 10 '23 17:03 joaquinricci