mobxjs / mobx

Simple, scalable state management.
http://mobx.js.org
MIT License
27.48k stars 1.77k forks source link

`ObservableSet.intersection` triggers "Maximum call stack size exceeded" stack overflow #3919

Closed travismfrank closed 3 weeks ago

travismfrank commented 3 weeks ago

Intended outcome:

Calling the newly implemented ObservableSet.intersection with another ObservableSet as the argument causes a stack overflow error. This is because an ObservableSet argument passes isES6Set, thus calling intersection on that set with the first set as the argument. Repeat ad infinitum until V8 decides it's had enough.

observableSet.intersection(otherObservableSet) should just work.

Actual outcome:

"Maximum call stack size exceeded" in Chrome. Stack overflow.

How to reproduce the issue:

const foo = observable.set(['a', 'b', 'c']);
const bar = observable.set(['c', 'd', 'e']);

const shared = foo.intersection(bar);

Here's an interactive version, just click the button.

Versions

mobx@6.13.1

urugator commented 3 weeks ago

Possibly broken by https://github.com/mobxjs/mobx/pull/3893/files . It introduced new isPlainES6Map, but not isPlainES6Set. Previously isES6Set yielded false for observable set.

urugator commented 3 weeks ago

Thank you for the report, should be fixed in mobx@6.13.2