whatwg / console

Console Standard
https://console.spec.whatwg.org/
Other
269 stars 67 forks source link

Define which methods should provide a stacktrace #203

Open whimboo opened 2 years ago

whimboo commented 2 years ago

While implementing stacktrace support for console API calls for the WebDriver BiDi support in Firefox I noticed differences between browsers. Per the specification we should include the stacktrace for the following methods:

If method is "assert", "error", "trace", or "warn", let stack be the current stack trace. Otherwise let stack be null.

Hereby Firefox does not add a stacktrace for calls to warn(), whereby Chrome does it.

It would be easy to add, but in general it would be great to have the availability of the stacktrace for methods defined in the console specification.

terinjokes commented 2 years ago

We do define at least one place where when a stack is expected: trace. In this instance, it's clear the behavior the developer wants.

Is the ask here to require agents to include the stack in their side effect actions? Or is the ask to make it clearer that agents may include a stack?

whimboo commented 2 years ago

I see. So the requirement for console commands to have a stacktrace included only exists for trace and for other commands it's up to the user agent to optionally provide that object? So yes, it might be good to have some paragraph that clarifies that in the console specification.

domfarolino commented 2 years ago

@whimboo Would you be willing to submit a spec PR for this? I'm happy to review it

whimboo commented 2 years ago

@domfarolino I think it depends on the outcome of the above discussion. Can I assume that you all are fine with only trace requiring a stacktrace and for all others it's optional? If that is clarified I may be able to create a PR. Thanks.

domfarolino commented 2 years ago

Sure, thanks for clarifying. Yes I think that sounds good to me, and would match implementations (i.e., Chrome adding stack trace information for console.warn()).

@terinjokes does this sound good?

terinjokes commented 2 years ago

That clarification, that it's optional for other logging methods, sounds fine by me.