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: minified version of Function.prototype.name feature detect is incorrect

See original GitHub issue

The feature detect for Function.prototype.name is this: 'name' in Function.prototype && (function x() {}).name === 'x' but when minified it is turned into this: "name"in Function.prototype&&"x"===function(){}.name which is incorrect because "x"===function(){}.name will always evaluate to false.

Pollyfills used: polyfill.js?features=default,es6 Pollyfill with issue: Object.defineProperty

stack trace:

defineProperty | @ | polyfill.js?features=default,es6:414
-- | -- | --
defineProp | @ | polyfill.js?features=default,es6:414
(anonymous function) | @ | app.js:1

I have a library somwhere inside one of my 1 million NPM packages that is trying to defined the property items ontop of an empty array (basically Object.defineProperty([], “items”, config)) however the issue is ONLY happening on iOS 8, every other browser is fine with it. For this reason I am unable to figure out which of the million packages is doing this as I browserstack for whatever reasons is having a bad day when it comes to sourcemaps.

This is making it so that I have 0 idea what is causing this error so I cannot just remove the package which is doing this and move on. All that being said, is it correct behaviour for the pollyfill service to fix this? I can’t even tell if pollyfill.js is pollyfilling my browser 😦

I know this is a useless issue submission with very little info but I’m really at my witts end and this is basically just a cry for help. I am just hoping sombody has seen this before and knows a way to fix it. I’m hoping that it’s not that I’m stuck and that theres somthing stupid I need to fix.

Sorry.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeChampioncommented, May 8, 2019

@rmja both your commands return 3.34.0 for me, I’m not sure what else to check here, I know polyfill-service uses 3.34.0 and I have emptied the cache in our CDN to ensure everyone get’s the latest version so long as they do not have a local cached copy.

I can confirm the bug this issue is about does exist in 3.34.0 via this url https://polyfill.io/v3/polyfill.js?flags=gated,always&features=Function.prototype.name&excludes=Object.defineProperty

/* Polyfill service v3.34.0
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 * 
 * Features requested: Function.prototype.name
 * 
 * - Function.prototype.name, License: MIT */

(function(undefined) {
if (!("name"in Function.prototype&&"x"===function n(){}.name
)) {

// Function.prototype.name
1reaction
JakeChampioncommented, Apr 3, 2019

@rmja, the symptom you are seeing is that the polyfill will not work in browsers which already support the feature. The reason that happens for your original request is because the user-agent is detected as one we do not support and so we serve it all the requested polyfills and put them behind feature detects however, the feature detects are served in a minified format and the minifier was not preserving the function names, which made the feature detect for function.prototype.name support always return false , even for browsers which do support function.prototype.name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to minify the code from this file - Stack Overflow
Now when I want to build my project I get an error: Failed to compile. Failed to minify the code from this file:...
Read more >
Handling common JavaScript problems - MDN Web Docs
These days, most cross-browser JavaScript problems are seen: When poor-quality browser-sniffing code, feature-detection code, and vendor prefix ...
Read more >
uglify-js - npm
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit. Note: uglify-js supports JavaScript and most language features in ...
Read more >
Firebase JavaScript SDK Release Notes - Google
Fixed a bug that caused Firebase SDKs to throw an error in Firefox browsers when third-party ... The minified version of the Cloud...
Read more >
JavaScript: Uncaught TypeError: n is not a function
This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to...
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