-
Notifications
You must be signed in to change notification settings - Fork 443
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
Partytown worker failing to initialize after passing non-serializable objects to postMessage #458
Partytown worker failing to initialize after passing non-serializable objects to postMessage #458
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
It looks like you have created a failing test case for us. ❤️ This is great! Any luck figuring out what the issue was? Not sure when I will get time to look into it, so if you can get a head start that would be great! |
After writing my previous comment, I realized that simply filtering for non-serializability might be too broad, as it would remove some objects entirely simply for having a non-serializable member that could instead be removed. I've added some code that aims to do the non-serializable member removal instead but that doesn't seem to work either. Later edit: I might be calling the function on the wrong level of nested arrays, but either way - getting to the constructor error might be indicating that I'm misunderstanding the issue and this isn't on the correct path to a fix either way :) P.S. Sorry for the code duplication, I don't view any of this as production viable code, just aiming to provide some extra debug info! |
What is it?
Description
After adding an example Klaviyo script tag, the Partytown workers fails to initialize because of the following error:
Further debugging shows that the Klaviyo object (
window.klaviyo
) is the culprit of the non-serializable objects (below links are images):Analyzing Klaviyo object serializability
Debug logs before initial
postMessage
call with the results ofreadMainPlatform
More information at the following Loom recording
In the Loom there seems to be weird behavior with reloading with/without cache and with the "Update on reload" option checked for the service worker.
Gists mentioned in recording:
Gist 1
Gist 2
Debugging
The debugging I did was on a different version of Partytown, but:
NB: I tried adding a check whether an object is serializable before pushing it to the interfaces array, which helped with initializing the worker, but it then started throwing errors about missing constructors (I remember it missing a constructor for
Element
), which made me think the solution might not be a simple serializability check.I can reproduce the debugging if that would help, but it's mostly just a
isSerializable
function and some console logs inreadOwnImplementation
.Checklist: