-
Notifications
You must be signed in to change notification settings - Fork 396
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
make when/debug track stack jumps #109
Comments
Maybe we could get a feel for what we really need if we had some minimal debugging functionality first. What if we used the promise
.then(function doSomething() { /* ... */ })
.then(function doSomethingElse() { /* ... */ })
.then(function iWillFail() { /* ... */ });
/*
Error: Chuck Norris told me to fail
- doSomething
- doSomethingElse
- iWillFail
*/ Then, we can play with variables like the maximum size of the trace, and whether or not show the resolution/rejection values and the other handlers attached to the promise. There's also another option: what if, instead of having a stack trace, we had an introspection API for these things? That way, the developer would be able to dig as deep as s/he thinks is valuable. |
It might be interesting to decouple this stuff even from |
Lots of good and relevant information is piling up over here |
This is potentially interesting as well. Either way, we need to collect the "right" information as the system runs, so step 1 seems like determining what the "right" information is. To get that discussion started, here's a short list of things that seem useful to collect, without worrying too much about how we'd do it :)
What else? |
Some good info in this G+ post on how to capture stack traces in v8 and possibly other engines. |
IE can be done with something like -- but hopefully more elegant than -- this SO post |
Cool. And I just remembered that stacktrace.js exists, which we may be able to use as inspiration. |
I've been playing with a very rough POC in this branch. I created a simple global API (currently hanging off console, but would be nice to find a better way) for reporting pending, rejected and previously-rejected-but-now-handled promises. when.js and when/monitor rendezvous on that API: when.js reports things, monitor collects them. It then matches the creation point of pending promises up with the rejection point of unhandled rejected promises, and outputs a list of all the currently know unhandled rejections. It's rough, but it's an interesting experiment, and the code is pretty simple. I'm hoping this sparks some ideas of where we can go with it :) |
I merged the POC to the dev branch. It seems like it's on the right track, although still could use lots of testing and feedback. Most recently, I added the ability to track stack chains from parent to child promises. That allows it to synthesize "long" stack traces that cross stack jump boundaries. It's def not perfect, but getting better. If you want to try it out, check out the |
This is now in dev and will be released in 2.2. See docs here |
As in #108. We've discussed a good bit on this previously, and it is doable, albeit tricky.
It would be nice if
when/debug
could produce meaningful stack traces from promise chains that span stack jumps.The text was updated successfully, but these errors were encountered: