New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 622227 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jun 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

console.log/console.warn should respect source maps when printing error stacks

Reported by m.go...@gmail.com, Jun 22 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce the problem:
1. Write a file in a language to be transpiled (like ES6 or CoffeeScript).
2. Produce an error in this file, try-catch it & console.warn its stack.
3.

What is the expected behavior?
The console should print an error with references to the original files according to source map mappings.

What went wrong?
The console prints information about the transpiled source code, not the original one as is the case if an error is normally thrown.

Did this work before? N/A 

Chrome version: 53.0.2774.2  Channel: canary
OS Version: OS X 10.11.5
Flash Version: Shockwave Flash 22.0 r0

This has hit jQuery 3.0 which has shipped with a Promises/A+-compatible promise implementation. That required us to try-catch errors happening in promise callbacks to turn them into rejections.

To make debugging a little easier while remaining standard-compliant we introduced a special hook (possible to override by users)[1] that console.warns the caught error if it's one of the types that are more likely a result of a user error than a legitimate promise rejection to be handled.

Unfortunately, this hook uses console.warn to log the error stack and DevTools don't apply the transformations to show the original file locations of various places in the stack trace. This makes debugging harder, especially for languages that differ more from JS so that the transpiled file is not that clear to read.

[1] https://github.com/jquery/jquery/blob/3.0.0/src/deferred/exceptionHook.js#L12-L19
 

Comment 1 by m.go...@gmail.com, Jun 22 2016

a jQuery issue that has screenshots and an example site showing the problem: https://github.com/jquery/jquery/issues/3179

Comment 2 by kbr@chromium.org, Jun 22 2016

Cc: kbr@chromium.org pfeldman@chromium.org
Cc: kozyatinskiy@chromium.org
Status: WontFix (was: Unconfirmed)
You console.warn text, we don't know if it is a stack. We could do a best-effort something here, but it would not be reliable. You could console.warn(e) instead of console.warn(e.stack). That way we know it is a stack and we can translate it. If we don't - let us know via posting into this bug.

Sign in to add a comment