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.

Invalid descriptor for property '0'

See original GitHub issue

In IE 11, I’m getting the error:

Invalid descriptor for property ‘0’

Walking up the call stack, it’s stemming from some code that is constructing a DOMTokenList with a body element and 'className':

e=new DOMTokenList(body, 'className');

…which eventually hits this code which throws the error:

_(y,n,r)
  • _ is some function named defineProperty
  • y is some object
  • n is 0
  • r is set to undefined

I’m using this polyfill URL (linebreaks added for readability):

https://cdn.polyfill.io/v2/polyfill.min.js
  ?unknown=polyfill
  &features=
    default%2C
    fetch%2C
    Array.prototype.%40%40iterator%2C
    Array.prototype.find%2C
    Array.prototype.findIndex%2C
    Function.name%2C
    Number.isFinite%2C
    Promise%2C
    String.prototype.repeat%2C
    Array.prototype.includes%2C
    Intl.~locale.en-US%2C
    Promise.prototype.finally

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
HenriqueLimascommented, Jul 5, 2019

With this code is possible to simulate on IE11 or also Chrome 37 (Before Symbol support) since it is easier to debug on Chrome:

delete Object.prototype[Symbol.toStringTag] // At some point the prototype key is being deleted

try {
  var a = {}
  Object.defineProperty(a, Symbol.toStringTag, { value: 42 })
} catch (error) {
  console.log('Ops error', error);  // "Property description must be an object: undefined"
}

console.log(a[Symbol.toStringTag]) // 42
console.log(a.propertyIsEnumerable(Symbol.toStringTag))
// Cannot read property '@@__symbol:toStringTag0.85429089097306135' of undefined 

At some point the key Symbol.toStringTag in the Object.prototype is being deleted. I am having this issue using Webpack + ReactUniversalComponent in dev mode.

6reactions
LachlanStuartcommented, Nov 16, 2018

Here’s the unminified stacktrace:

TypeError: Invalid descriptor for property '0'
   at setDescriptor (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:1812:4)
   at defineProp (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:1715:4)
   at defineGetter (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:2609:4)
   at addIndexGetter (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:2633:4)
   at reindex (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:2644:6)
   at preop (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:2681:4)
   at _DOMTokenList (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:2685:3)
   at Anonymous function (https://cdn.polyfill.io/v2/polyfill.js?features=default,es6,es7,es2017,fetch,IntersectionObserver:3022:11)

That setDescriptor function is from the Symbol polyfill:

	setDescriptor = function (o, key, descriptor) {
		var protoDescriptor = gOPD(ObjectProto, key); // gOPD = The original Object.getOwnPropertyDescriptor, before being wrapped by this polyfill
		delete ObjectProto[key];
		defineProperty(o, key, descriptor);  // This line succeeds with args: o = _DOMTokenList, key = '0', descriptor = {configurable: false}
		if (o !== ObjectProto) {
			defineProperty(ObjectProto, key, protoDescriptor); // This line throws the exception with args: ObjectProto = Object.prototype, key = '0', protoDescriptor = undefined
		}
	};

If I try the same call in Firefox (Object.defineProperty(Object.prototype, '0', undefined)) I get the error TypeError: descriptor must be an object, got undefined, so this probably isn’t exclusively an IE11 bug, it probably occurs in IE11 because IE is the only major browser that gets the DOMTokenList polyfill.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using a custom decorator on a get accessor, why do I ...
You have set a get method and value in the descriptor, but this is invalid (you can have accessors or value, not both)....
Read more >
Object.defineProperty() - JavaScript - MDN Web Docs
This method allows a precise addition to or modification of a property on an object. Normal property addition through assignment creates ...
Read more >
Boost Graph Library: Adjacency List - 1.55.0
The property maps obtained from the adjacency_list class are models of the Lvalue ... Note that in this discussion iterator and descriptor invalidation...
Read more >
descriptor.h | Protocol Buffers - Google Developers
Gets a field by index, where 0 <= index < field_count(). more. ... The underlay remains property of the caller; it must remain...
Read more >
Descriptor for Applications, Components, and ... - SAPUI5 SDK
The data of the app descriptor is stored in JSON format in the manifest.json file. ... The ui5:// URLs have the following properties:....
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