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

Is it possible to have long stack traces? #99

Open
amasad opened this issue Jun 10, 2015 · 9 comments
Open

Is it possible to have long stack traces? #99

amasad opened this issue Jun 10, 2015 · 9 comments

Comments

@amasad
Copy link

amasad commented Jun 10, 2015

In addition to that there are some errors that are very cryptic:

Example snippet:

TypeError: Cannot read property 'length' of null
    at Promise._94 

Are there any plans to enhance the UX?

cc @ForbesLindesay

@ForbesLindesay
Copy link
Member

Yes, I would love to see long stack traces implemented. We can use Q as a good example of a library that already implements them. We should make them disabled by default and allow people to require('promise/lib/long-stack-traces') if they want them enabled.

@amasad
Copy link
Author

amasad commented Jun 10, 2015

Can you help me understand this stacktrace:

 ERROR  Cannot read property 'length' of null
TypeError: Cannot read property 'length' of null
    at Promise._94 (react-native-github/node_modules/promise/lib/core.js:138:31)
    at Promise._82 (react-native-github/node_modules/promise/lib/core.js:129:8)
    at react-native-github/node_modules/promise/lib/core.js:97:24
    at flush (react-native-github/node_modules/promise/node_modules/asap/raw.js:50:29)
    at process._tickCallback (node.js:415:13)

@amasad
Copy link
Author

amasad commented Jun 10, 2015

Apparently it's a race. After tracing back this call stack to the original source it seems that asap is calling twice (and finalizing) on the same promise. If I change a part of my code from Promise.all to a serial chain this works fine.

@ForbesLindesay
Copy link
Member

Interesting. Can you share the code to reproduce this? It sounds like this might be related to #93 but I was never able to get code to reproduce that.

@amasad
Copy link
Author

amasad commented Jun 10, 2015

let me try and boil it down to something reproducible.
Another random thought, could this be an issue with interop with a different promise library like bluebird?

@ForbesLindesay
Copy link
Member

It's definitely possible. Either way I really want to get to the bottom of it. If there's a bug in asap or this lib then finding it would be a huge win.

@ForbesLindesay
Copy link
Member

I've reconstructed as much as I can of what the original stack trace should look like. Unfortunately it doesn't tell me much extra:

TypeError: Cannot read property 'length' of null
    at Promise._finale (react-native-github/node_modules/promise/lib/core.js:138:31)
    at Promise._resolve (react-native-github/node_modules/promise/lib/core.js:129:8)
    at react-native-github/node_modules/promise/lib/core.js:97:24
    at flush (react-native-github/node_modules/promise/node_modules/asap/raw.js:50:29)
    at process._tickCallback (node.js:415:13)
From previous event:
    at Promise._handle (react-native-github/node_modules/promise/lib/core.js:87)

@amasad
Copy link
Author

amasad commented Jun 11, 2015

I couldn't reproduce outside of the codebase. I'm going to have to add you to my (internal) diff and you only have to change from bluebird to promise to start reproing

@ForbesLindesay
Copy link
Member

It turns out this is (as you suspected) caused by asap sometimes calling back twice and sometimes not at all. The offending issue is kriskowal/asap#55, which has now been resolved. Updating asap should be sufficient, which should happen automatically if you delete any caches and re-install.

I will release an update of promise that requires the latest version of asap though to encourage people to update faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants