console.log/console.warn should respect source maps when printing error stacks
Reported by
m.go...@gmail.com,
Jun 22 2016
|
|||
Issue descriptionUserAgent: 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
,
Jun 22 2016
,
Jun 23 2016
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 |
|||
Comment 1 by m.go...@gmail.com
, Jun 22 2016