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

Unable to destroy Lock instance #907

Closed
sandrinodimattia opened this issue Mar 7, 2017 · 6 comments · Fixed by #1653
Closed

Unable to destroy Lock instance #907

sandrinodimattia opened this issue Mar 7, 2017 · 6 comments · Fixed by #1653
Assignees
Labels
bug This points to a verified bug in the code

Comments

@sandrinodimattia
Copy link
Member

Hey guys,

I see this error when I call lock.destroy():

Uncaught TypeError: Cannot read property 'getIn' of undefined
    at http://localhost:3001/assets/vendors.js:16215:15
    at getUIAttribute (http://localhost:3001/assets/vendors.js:7967:10)
    at Object.avatar (http://localhost:3001/assets/vendors.js:7984:12)
    at http://localhost:3001/assets/vendors.js:6961:25
    at Object.render-1 (http://localhost:3001/assets/vendors.js:12553:20)
    at http://localhost:3001/assets/vendors.js:15998:24
    at Array.forEach (native)
    at Atom._change (http://localhost:3001/assets/vendors.js:15997:26)
    at Atom.swap (http://localhost:3001/assets/vendors.js:15969:17)
    at swap (http://localhost:3001/assets/vendors.js:12566:21)
    at removeLock (http://localhost:3001/assets/vendors.js:7289:19)
    at Auth0Lock.destroy (http://localhost:3001/assets/vendors.js:7061:29)
    at Auth0Lock.<anonymous> (http://localhost:3001/assets/client.js:35:12)
    at Auth0Lock../node_modules/events/events.js.EventEmitter.emit (http://localhost:3001/assets/vendors.js:31155:17)
    at http://localhost:3001/assets/vendors.js:8337:35
@luisrudge
Copy link
Contributor

@sandrinodimattia can you share more about this? what lock version, how are you instantiating lock, how are you calling lock.show()?

@luisrudge luisrudge self-assigned this Mar 17, 2017
@luisrudge
Copy link
Contributor

I can repro this. We'll fix this eventually. Since it's not a documented API, I'm assigning this with a low priority

@iorrah
Copy link

iorrah commented May 7, 2018

Hey @luisrudge, just landed on this thread from March 2017 and was wondering if lock.destroy() will be tackled any time soon?

This seems to be specially useful in React apps to avoid memory leaks. Example:

import Auth0Lock from 'auth0-lock';

export class MyComponent extends React.Component {
  constructor() {
    super();
    this.state = {
      lock: null,
    };
  }

  componentWillUnmount() {
    const { lock } = this.state;

    if (lock) {
      lock.destroy();
    }
  }

  componentDidMount() {
    const lock = new Auth0Lock(clientID, domain, options);
    lock.show();
    this.setState({ lock });
  }

  render() {
    // ...
  }
}

When I try to implement the trigger above, the following error pops up:

Dynamic page loading failed TypeError: Cannot read property 'getIn' of undefined
  at eval (data_utils.js:20)
  at getUIAttribute (index.js:280)
  at Object.avatar (index.js:297)
  at eval (core.js:100)
  at Object.eval [as render-1] (index.js:31)
  at eval (atom.js:54)
  at Array.forEach (<anonymous>)
  at Atom._change (atom.js:53)
  at Atom.swap (atom.js:25)
  at swap (index.js:44)

For reference, I'm using [email protected]. Let me know if there is any additional info that I can provide to help!

@luisrudge
Copy link
Contributor

When the component is unmounted, GC will get rid of your internal state, so there's no memory leaks. Yes, we still have to fix this and there's a PR to fix it: #1091 - but this PR touches in a crucial part of the widget and I didn't have time to test all features of lock to make sure everything works.

@jkhlim
Copy link

jkhlim commented Nov 12, 2018

Just want to add a +1 to this feature.

@luisrudge
Copy link
Contributor

dupe #1090

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

Successfully merging a pull request may close this issue.

5 participants