Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problematic comparison in store : observe() : subscribe() #1090

Closed
UnsungHero97 opened this issue Aug 20, 2017 · 3 comments
Closed

Problematic comparison in store : observe() : subscribe() #1090

UnsungHero97 opened this issue Aug 20, 2017 · 3 comments
Labels
bug This points to a verified bug in the code

Comments

@UnsungHero97
Copy link

Auth0 Lock v10.20.0

I'm using an undocumented API method, lock.destroy(), and I encountered issue #907. After tracing the code, I think I've found a problematic comparison that leads to that issue:

lock/src/store/index.js

Lines 8 to 10 in 7f0e0b5

const m = getEntity(newState, 'lock', id);
const oldM = getEntity(oldState, 'lock', id);
if (m != oldM) f(m);

Once destroy() is invoked, getEntity() returns undefined for both m and oldM, which means f(m) will be invoked with m being undefined, which then causes Uncaught TypeError: Cannot read property 'getIn' of undefined in #907.

Shouldn't this check instead be:

if (m && oldM && m != oldM) f(m);

...? Furthermore, since both m and oldM are both immutable-js Maps, shouldn't m != oldM instead be !m.equals(oldM)?

@luisrudge
Copy link
Contributor

🎉 Thanks. Would you mind sending a PR to fix this?

@UnsungHero97
Copy link
Author

@luisrudge, here you go!

#1091

@luisrudge luisrudge added the bug This points to a verified bug in the code label May 22, 2019
@luisrudge
Copy link
Contributor

fixed in #1653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants