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

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') #38

Closed
lizryzhko opened this issue Dec 2, 2021 · 5 comments

Comments

@lizryzhko
Copy link

lizryzhko commented Dec 2, 2021

Hi. I just tried to use this library for the first time, got the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
    at partytown-sandbox-sw.js:304
    at Array.map (<anonymous>)
    at readMainPlatform (partytown-sandbox-sw.js:300)
    at accessRsp.$msgId$ (partytown-sandbox-sw.js:373)
    at Worker.worker.onmessage (partytown-sandbox-sw.js:422)
(anonymous) @ partytown-sandbox-sw.js:304
readMainPlatform @ partytown-sandbox-sw.js:300
accessRsp.$msgId$ @ partytown-sandbox-sw.js:373
worker.onmessage @ partytown-sandbox-sw.js:422

here docImpl.createElement("i").constructor.name returns b, and win.b is undefined. 🤷‍♀️

@adamdbradley
Copy link
Contributor

What browser are you receiving this error? Would you be able to create a minimal example to reproduce this? Thanks

@davidmerrique
Copy link

davidmerrique commented Dec 10, 2021

@adamdbradley I'm getting a similar error. All browsers, Chrome, FF, Safari

I have it set up like this

<script>
    partytown = {
      lib: "/js/~partytown/",
      debug: true,
      forward: [['dataLayer', 1]],
      logCalls: true,
      logGetters: true,
      logSetters: true,
      logImageRequests: true,
      logMainAccess: true,
      logSendBeaconRequests: true,
      logStackTraces: false,
      logScriptExecution: true,
    };
  </script>
<script src="/js/~partytown/debug/partytown.js"></script>
<script type="text/partytown">
  (function (window, document, i) {
    window['dataLayer'] = window[dataLayer] || [];

    window['dataLayer'].push({ 'gtm.start': new Date().getTime(), 'event': 'gtm.js' });

    var firstScript = document.getElementsByTagName('script')[0];
    var gtmScript = document.createElement('script');
    var dataLayer = 'dataLayer' != 'dataLayer' ? '&l=' + 'dataLayer' : '';

    gtmScript.async = true;

    gtmScript.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dataLayer;

    firstScript.parentNode.insertBefore(gtmScript, firstScript);
  })(window, document, 'GTM-REDACTED');
</script>

And i'm getting this error:

url: https://www.googletagmanager.com/gtm.js?id=GTM-REDACTED TypeError: Cannot read properties of undefined (reading 'createElement')
    at eval (eval at re (partytown-ww-sw.js:1), <anonymous>:36:242)
    at eval (eval at re (partytown-ww-sw.js:1), <anonymous>:36:402)
    at eval (eval at re (partytown-ww-sw.js:1), <anonymous>:37:271)
    at eval (eval at re (partytown-ww-sw.js:1), <anonymous>:48:326)
    at Proxy.eval (eval at re (partytown-ww-sw.js:1), <anonymous>:493:3)
    at re (partytown-ww-sw.js:1)
    at partytown-ww-sw.js:1

@edstarck
Copy link

edstarck commented Dec 24, 2021

Hey!
I'm getting a similar error.
Help me please.

const doc = win.document;
const docImpl = doc.implementation.createHTMLDocument();
const elm = docImpl.createElement("i");
elm.constructor.name // returns 'b' but not 'HTMLElement'

elm.constructor  - > ƒ (){return a.Reflect.construct(a.HTMLElement,[],this.constructor)}
but not
elm.constructor  - > ƒ HTMLElement() { [native code] }

Why?
I hope for your help. Thanks.

@eliseumds
Copy link

eliseumds commented Jan 5, 2022

It conflicts with gpt.js:

<script src="//securepubads.g.doubleclick.net/tag/js/gpt.js" />

@naveedahmed1
Copy link

Any update on this? I am also receiving this error:

partytown-sandbox-sw.html?1646610283529:2 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
    at partytown-sandbox-sw.html?1646610283529:2:5241
    at Array.map (<anonymous>)
    at P (partytown-sandbox-sw.html?1646610283529:2:5191)
    at partytown-sandbox-sw.html?1646610283529:2:6635
    at Worker.W.onmessage (partytown-sandbox-sw.html?1646610283529:2:25463)

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

6 participants