question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Chrome/49 - Cannot redefine property: hasInstance

See original GitHub issue
  • Browser: Chrome/49.0.2623.112
  • Os: Windows NT 6.0
  • Error: Cannot redefine property: hasInstance

Error as described in Datadog

TypeError: Cannot redefine property: hasInstance
  at Function.defineProperty @ <anonymous>
  at <anonymous> @ https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015%2CNodeList.prototype.forEach%2Cfetch:3:17056
  at <anonymous> @ https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015%2CNodeList.prototype.forEach%2Cfetch:3:25647

User-Agent as described in Datadog

Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

I tried creating a simple html and spoofing the user agent, but it still happened.

test.html

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>test</title>
    <script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=Symbol.hasInstance"></script>
  </head>
  <body>
    test
  </body>
</html>

Error as described in Chrome Console

Uncaught TypeError: Cannot redefine property: hasInstance
    at Function.defineProperty (<anonymous>)
    at polyfill.min.js?features=Symbol.hasInstance:3
    at polyfill.min.js?features=Symbol.hasInstance:3

I think it’s the correct behavior to be called in Chrome version 49. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance

I think the chrome = "< 50" setting in the config for hasInstance is also correct. https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/Symbol/hasInstance/config.toml#L13

I check into it so far, but I’m just not sure.

Please confirm the above.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
JakeChampioncommented, Dec 16, 2020

Uh, no. I’ve been spoofed by a user agent, but the version of Chrome itself is newer so it’s an incorrect action?

Correct, spoofed user agents is not something polyfill.io supports. You need to use the real Chrome 49 to test it, which I’ve done above and shown is working correctly

1reaction
JakeChampioncommented, Dec 16, 2020

I’ve tested this in Chrome 49 and it does not throw an error:

image

This is the site I tested with: – https://jsbin.com/judugiqari/edit?html,output

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>test</title>
  </head>
  <body>
  </body>
  <script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=Symbol.hasInstance"></script>
  <script>
    document.body.innerHTML = 'Symbol.hasInstance: ' + !!Symbol.hasInstance
    </script>
</html>
Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] TypeError: Cannot redefine property: webdriver #185
Environment chrome-aws-lambda 5.5.0: puppeteer-core 5.5.0: OS: Mac Node.js Version: 14.x Current Behavior Error: TypeError: Cannot redefine ...
Read more >
Reimplemented Constructor[Symbol.hasInstance] but it still ...
It returns false : you cannot write to the Symbol.hasInstance property of a function with the assignment = operator. The property never gets ......
Read more >
Origami Newsletter, December 2020 - Financial Times
[Bug] Chrome/49 - Cannot redefine property: hasInstance ... Allow getters and setters to be set to undefined and not throw an error.
Read more >
393988 - TypeError: Cannot redefine property: stack - chromium
The following code runs fine on M36. But it throws "Cannot redefine property: stack" in M37. Is this a regression? <!DOCTYPE html>
Read more >
Symbol.toStringTag - JavaScript - MDN Web Docs
toStringTag well-known symbol is a string valued property that is used in the creation of the default string description of an object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found