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.

Cannot read property 'then' of undefined

See original GitHub issue

Current behavior

I’m getting a lot of Sentry error reports on 3528:48

    _createClass(SweetAlert, [{
      key: "then",
      value: function then(onFulfilled) {
        var promise = privateProps.promise.get(this); // <-- This line, specifically the 'this'
        return promise.then(onFulfilled);
      }
    }, {
      key: "finally",
      value: function _finally(onFinally) {

I’m trying to reproduce it myself and so far have been unable to do so. It seems this crash can happen as soon as loading the page.

Expected behavior

I would expect the code to handle when promise is undefined. Perhaps there’s a race condition happening here?

Live demo

I’ll just note again I haven’t been able to reproduce it myself, so I would love some advice on what I could do to perhaps test this part of the code and reproduce the issue I’m seeing.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
BoldBigflankcommented, Dec 29, 2020

Yeah I’ll say the solution was to call the function only on views that exist and close this out.

1reaction
BoldBigflankcommented, Dec 29, 2020

Got some extra help and found that the issue has something to do with the page’s navigation messing with the weakmap promise implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'then' of undefined
TypeError : Cannot read property 'then' of undefined when calling a Django service using AngularJS. If you are calling a Python service, ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
What Causes TypeError: Cannot Read Property of Undefined. Undefined means that a variable has been declared but has not been assigned a value....
Read more >
Cannot read property 'then' of undefined" when mocking ...
Describe the bug I have the following interface in TypeScript: interface Something { getValueAsync: () => Promise } I'm trying to create a ......
Read more >
Cannot read property 'then' of undefined - Promise - Reddit
I have a function to fetch some data. The last block is also inside a async block. Now the question is why is...
Read more >
Jamming - TypeError: Cannot read property 'then' of undefined
When you see a TypeError: Cannot read property 'whatever' of undefined, the place to start looking is where 'whatever' is attached to should ......
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