-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Failed to execute 'postMessage' on 'Worker' when worker:true and using transformHeader function #623
Comments
I have the same issue for the transform callback. Is this feature fully implemented? |
Functions are not transferable so in worker mode a different strategy should be used. I can think of 2 options:
|
It is possible to pass a simple function to a web worker, although a bit hackish. You would convert the function to a string then use eval in the work to re-inflate it. For example: From the UI thread.
In the worker:
|
@rbrundritt wow, this is really tricky but I do not think there is another workarround. Do you think we can document it and thus close this issue? |
That won't work if you use a CSP that prevents eval() to protect against XSS though... |
Going through same issue. Do we have any recommended solution or documentation related to this issue? |
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.
Sorry, I haven't actually been maintaining this library for several years now. @pokoli is your person! :) |
ping |
@0biWanKenobi do you have any proposal to solve the issue? |
any update on this? |
I'm getting the same for Papa.parse(event.target.files[0], {
worker: true,
header: true,
dynamicTyping: true,
beforeFirstChunk: function (chunk) {
debugger;
return chunk;
},
chunk: function chunk(results, parser) {
debugger;
}
}); |
I now do somewhat understand the issue: Function cannot be 'posted' / used in a Worker. I see that PapaParse does something special for only functions like step, chunk, complete and error, and not for the other function parameters: Lines 213 to 216 in e2d570e
But I also see when I'm not using Papa.RemoteChunkSize = Papa.LocalChunkSize = 10 * 1024; Oh, nvm, when you use a worker I guess the above chunksizes are now available and you need to fill Don't have enough knowledge to fix it. I see there some bad attempts made for the transform in a push request 😅 |
This appears to still be an issue as of today (Aug 2024), when using the |
Using Papa v5.0.0-beta.0 trying to use transformHeader config as follow:
Papa.parse(file, { header: true, preview: 1000, worker: true, transformHeader: function (header) { return header; } });
and getting error:
Error: Failed to execute 'postMessage' on 'Worker': function (header) { return header; } could not be cloned.
What am I missing?
Thank you
The text was updated successfully, but these errors were encountered: