You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to integrate Partytown into a CraftCMS website using the HTML implementation; I ran into some issues and did some debugging that may be useful for others trying to identify issues with their implementation effort.
I followed the HTML integration steps and ran into the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
at VM2608 partytown-sandbox-sw.js:527:56
at Array.map (<anonymous>)
at readImplementations (VM2608 partytown-sandbox-sw.js:517:67)
at readMainPlatform (VM2608 partytown-sandbox-sw.js:497:27)
at VM2608 partytown-sandbox-sw.js:583:56
at worker.onmessage (VM2608 partytown-sandbox-sw.js:593:69)
I did a bit of digging with debug: true and added some logging to the debug files, like this:
constreadImplementations=(impls,interfaces)=>{console.log(JSON.stringify(impls,null,2))constcstrs=newSet(["Object"]);constcstrImpls=impls.filter((implData=>implData[0])).map((implData=>{constimpl=implData[0];constinterfaceType=implData[1];constcstrName=getConstructorName(impl);console.log({
cstrName,
impl,
interfaceType,'mainWindow[cstrName]': mainWindow[cstrName],})constCstrPrototype=mainWindow[cstrName].prototype;// this is the line which caused the errorreturn[cstrName,CstrPrototype,impl,interfaceType];}));cstrImpls.map((([cstrName,CstrPrototype,impl,intefaceType])=>readOwnImplementation(cstrs,interfaces,cstrName,CstrPrototype,impl,intefaceType)));returninterfaces;};
and found an object o which has no entry in mainWindow under its cstrName. It's picked up when readImplementations reads the implementation for intersectionObserver from the impls array in readMainPlatform, as part of initWebWorkerData:
constintersectionObserver=getGlobalConstructor(mainWindow,"IntersectionObserver");//...constimpls=[[mainWindow.history],[perf],[perf.navigation],[perf.timing],[screen],[screen.orientation],[mainWindow.visualViewport],/*here*/[intersectionObserver,12],[mutationObserver,12],[resizeObserver,12],[textNode],[comment],[frag],[shadowRoot],[elm],[elm.attributes],[elm.classList],[elm.dataset],[elm.style],[docImpl],[docImpl.doctype]];//...constinitWebWorkerData={$config$: $config$,$interfaces$: readImplementations(impls,initialInterfaces),/* here */$libPath$: newURL(libPath,mainWindow.location)+"",$origin$: origin};
after adding some logging, I was able to determine the above and did some investigating in the devtools console. I found that o is defined by a third party script mutiny, a third-party A/B testing script. For what it's worth I did not attempt to run this script with partytown (it has to run synchronously to prevent any render delays).
I confirmed that removing the mutiny script from my site's head tag allows Partytown to initialize the web worker successfully. However this isn't a viable fix for production as we need to keep Mutiny. I want to create an issue for this, but I'm not sure how to create a reproducible example for this because it may be specific to Mutiny's implementation? I'd like to open a PR to fix this. I think something like this would suffice:
constreadImplementations=(impls,interfaces)=>{console.log(JSON.stringify(impls,null,2))constcstrs=newSet(["Object"]);constcstrImpls=impls.filter((implData=>implData[0])).map((implData=>{constimpl=implData[0];constinterfaceType=implData[1];constcstrName=getConstructorName(impl);console.log({
cstrName,
impl,
interfaceType,'mainWindow[cstrName]': mainWindow[cstrName],})if(!mainWindow[cstrName]){console.warn('No constructor found for',cstrName)return}else{constCstrPrototype=mainWindow[cstrName].prototype;return[cstrName,CstrPrototype,impl,interfaceType];}}));cstrImpls.filter(x=>x).map((([cstrName,CstrPrototype,impl,intefaceType])=>readOwnImplementation(cstrs,interfaces,cstrName,CstrPrototype,impl,intefaceType)));returninterfaces;};
^ I think readImplementations just needs some way to handle the case when mainWindow[cstrName] is undefined
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to integrate Partytown into a CraftCMS website using the HTML implementation; I ran into some issues and did some debugging that may be useful for others trying to identify issues with their implementation effort.
I followed the HTML integration steps and ran into the following error:
I did a bit of digging with debug: true and added some logging to the debug files, like this:
and found an object
o
which has no entry inmainWindow
under itscstrName
. It's picked up whenreadImplementations
reads the implementation forintersectionObserver
from theimpls
array inreadMainPlatform
, as part ofinitWebWorkerData
:after adding some logging, I was able to determine the above and did some investigating in the devtools console. I found that
o
is defined by a third party scriptmutiny
, a third-party A/B testing script. For what it's worth I did not attempt to run this script with partytown (it has to run synchronously to prevent any render delays).I confirmed that removing the mutiny script from my site's
head
tag allows Partytown to initialize the web worker successfully. However this isn't a viable fix for production as we need to keep Mutiny. I want to create an issue for this, but I'm not sure how to create a reproducible example for this because it may be specific to Mutiny's implementation? I'd like to open a PR to fix this. I think something like this would suffice:^ I think
readImplementations
just needs some way to handle the case whenmainWindow[cstrName]
is undefinedBeta Was this translation helpful? Give feedback.
All reactions