-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DDC doesn't offer a way to log formatted errors/traces #33331
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
Comments
As mentioned by @vsmenon - this is fixed if I enable "Custom Formatters" in devtools: http://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html |
Actually will reopen because I'm confused how Dart2JS does this for free. |
Ping. Is this a bug? Intentional? Something else? |
It's not exactly free. Dart2JS is wrapping all throws in a JS Error object and unwrapping on a catch. Chrome dev tools (but not node) formats the native DDC could do similar, though it would increase code size on throw / catch. |
Do we know what the cost is? Seems a bit suspect that it is OK for production but not the dev compiler. |
It's a question of JS interop spec: when a Dart object is thrown, what should JS see (and vice versa)? Do we wrap all thrown Dart objects in a JS Error, or only some of them (e.g. only things that extend or implement dart:core Error/Exception)? The DDC/Dart 2 approach is to use wrapperless interop when possible. There are many benefits to that in general. I think we hit a problem here because most Dart Error/Exception types do not correspond to JS Error. I think there may be a mismatch in stack traces between JS and Dart, which is why we kept them distinct (I think JS Errors capture stack at creation, rather than when thrown). Considering all of that, the simplest approach is probably to wrap all throws. I don't think it will be a noticeable perf issue because IIRC, we already create JS Error objects anyways for stack traces. |
Thanks @jmesserly!
Which I'd also love ;)
Hard to answer that question definitively. Here are some questions:
My guess is making all Dart errors JS errors feels "right", and where/when it isn't possible, we can just not do it. Personally this is part of the language that doesn't make a lot of sense to me - I can sort of see
Could you explain in 1 or 2 sentences what that is and why that benefits users?
My read of this is you agree that Dart2JS and DDC should have similar semantics here? |
Generally: wrapperless interop performs better, allows passing complex structures (e.g. objects of user-defined classes), provides identity semantics, allows incremental porting and/or hybrid apps (because each language can express all of the necessary operations on the same shared data structures). It also makes writing the interop API signatures easier.
Yes. |
Thanks! |
This fell off a bit, /cc @vsmenon for now. How can we act on this? |
We should be encouraging folks to enable custom formatters immediately (per https://webdev.dartlang.org/guides/debugging). Flagging for @jmesserly to update when she's back. I suspect we'll want to do this in conjunction with #34060. |
Any more action here? |
Sort of :). I started taking a look at this yesterday as I was reviewing bugs. Will update when I have a CL ready. |
Thanks! Just doing a bug scrub - there is an usptream google3 bug blocked on this one. |
I'm juggling a lot of things right now :), but I did manage to finally upload my fix for this: https://dart-review.googlesource.com/c/sdk/+/84446 |
Hi, I have a problem with the formatting of stack traces. I am using stagehand ( example code: void main(){
throw '123123123';
} |
Ping @jmesserly 😛 |
This improves the default JS display of exceptions/errors from DDC compiled code. This gives a better "default" experience if JS code (or a JS engine, like browers/Node.js) ends up catching Dart exceptions. Change-Id: Ib2dda6eee710f8b536d5ed7223e0101310a137b3 Reviewed-on: https://dart-review.googlesource.com/c/84446 Commit-Queue: Jenny Messerly <[email protected]> Reviewed-by: Vijay Menon <[email protected]>
I landed a CL that changes DDC to throw JS errors--they'll be better understood by JS tools, etc. Tracking of the Dart StackTrace object is improved for That sounds like it'll address your original issue, but I'm not 100% sure (were there other things you wanted?) |
Added "needs-info" ... LMK if there's anything else you need (or, should we open another issue for additional requests?) |
Thanks! Is that expected to make it into google3 anytime soon? If so, we can close this! |
SGTM! thank you |
edit: yeah it'll make it in the next roll; or it may have already happened (I'm not sure what the holiday schedule was). But in any case, yeah, soon. |
sadly need to revert this for now, there are some (very obscure) failures in a few tests. I wasn't able to make too much sense of it, but it looks like code may be relying on DDC's former, incorrect behavior. When async code loses a stack trace, and passes in explicit "null" where a trace is expected, we used to keep the old stacktrace (the thrown object stored it). That's not technically correct behavior in DDC, but it's useful. Perhaps I can back out of some parts of the CL, while keeping the "always throw JSError" part. Needs more investigation. |
😢
What code? Clients in google3? The SDK itself? If its the latter, I don't mind helping to debug. |
It wasn't clear who was passing in the (That might not even be the root cause, but it is odd. A future then handler should never be passed "null" as the stack trace.) |
wow, spoke too soon, turns out my "shot in the dark" may have worked. Either the "preserve stacktrace when null is passed" or the "preserve original stack trace, even when |
This issue is blocking resolution of angulardart/angular#1367.
Almost everything can be viewed at angulardart/angular#1367, but basically:
throw
should log a nice JavaScript error and stack trace by default.For example, I'd like the output in the browser to look like this when we are done:
(Obviously not minified, this is just an example from Dart2JS that works fine)
Instead of this:
The text was updated successfully, but these errors were encountered: