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

Created on 16 Dec 2020  路  5Comments  路  Source: Financial-Times/polyfill-service

  • 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.

service

Most helpful comment

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

All 5 comments

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>

I also tested on the same page, but an error has occurred. Hmm, Why...?

JS_Bin_-_Collaborative_JavaScript_Debugging

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

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

Okay, I understand.
The user who was notified of the error may have also been spoofing the user agent.

Thank you very much for your answer!

Was this page helpful?
0 / 5 - 0 ratings