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.

inspect should skip properties that begin with $

See original GitHub issue

Opal (Ruby to JavaScript transpiler) adds special properties to all objects which introduce a circular graph. For example:

require('opal-runtime')

const a = []
console.log(a['$class']['$class']['$class']['$class']['$class']['$class'])

When inspect encounters one of these objects, it enters an infinite recursion and hangs.

inspect should skip properties on an object that begin with $. If not the default, it should provide a configuration switch to activate this filtering.

You could debate that Opal should not be adding properties that are accessible via (for name in obj). The problem is, the Opal creators don’t agree, and that leaves us all that use it with test suites that hang on failures.

Here’s the proposed change to getEnumerableProperties.js.

module.exports = function getEnumerableProperties(object) {
  var result = [];
  for (var name in object) {
    if (!name.startsWith('$')) result.push(name);
  }
  return result;
};

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mojavelinuxcommented, Jun 9, 2018

That’s fine. In fact, the discussion prompted a change in Opal itself. Opal is now going to define properties using the defineProperty mechanism (with enumerable set to false), which will exclude them from being picked up by for…in. See https://github.com/opal/opal/commit/34f89df1d700be5143b9dbcc9886202fd2bfd3ca

1reaction
keithamuscommented, Jan 26, 2018

chai should not hang the node process and eat up 100% of the CPU

Yep. Absolutely. There’s two problems here. Firstly the inspection engine hangs. This will be fixed in the next few months as we introduce loupe as a new inspection engine, which fixes circular refs. The next problem is why the inspection engine is ever run for passing tests. This is addressed in #585 which is a much longer architectural change.

I’m saying let’s deal with a problem we have this ecosystem that’s real.

This is a valid concern, but Opal is one library out of N. Making concessions for individual libraries is not something we’re interested in doing, as its a slippery slope. We could also block the $$typeof$$ magic strings that some libraries like React have, but its not an interest we have. Again though, the new inspection engine will enable plugins to interface with these paths to allow for this kind of behavior.

TL;DR. Sorry, it sucks that this is the case right now. We’re working hard to fix it. Rest assured it will be fixed - just not in the exact way that Opal declares it’s circular properties.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python inspect get methods decorated with @property
For now I am doing methods = inspect.getmembers(cls[1], lambda x: inspect.ismethod(x) or isinstance(x, property)) I am also curious if there ...
Read more >
Auto-property can be made get-only (non-private accessibility)
You can suppress this inspection to ignore specific issues, change its severity level to make the issues less or more noticeable, or disable...
Read more >
10 Reasons You Shouldn't Skip A Home Inspection
4. Protection. Home inspections are even more critical if you are buying an "as-is" foreclosed property or short sale. Dwellings that have been...
Read more >
Properties in C# | Microsoft Learn
Learn about C# properties, which include features for validation, computed values, lazy evaluation, and property changed notifications.
Read more >
Open Chrome DevTools
To inspect, right-click an element on a page and select Inspect. The Inspect option in a drop-down menu in Chrome. DevTools opens the...
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