Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Very incorrect column numbers in exception stack text #527

Closed
andrewschaaf opened this issue Dec 21, 2010 · 4 comments
Closed

Very incorrect column numbers in exception stack text #527

andrewschaaf opened this issue Dec 21, 2010 · 4 comments

Comments

@andrewschaaf
Copy link

echo '(function(){try{JSON.parse("not JSON")}catch(e){console.log(e.stack);}})();' > foo.js; node foo.js
SyntaxError: Unexpected token ILLEGAL
    at Object.parse (native)
    at /Users/a/Desktop/nodejs-col-fail/min.js:1:84
    at Object. (/Users/a/Desktop/nodejs-col-fail/min.js:1:134)
    at Module._compile (node.js:357:32)
...

1:84 and 1:134 are out of bounds! (only 75 chars of code)

(node v0.3.2)

If you add two \ns, it works perfectly:

(function(){try{
JSON.parse("not JSON")
}catch(e){console.log(e.stack);}})();
@andrewschaaf
Copy link
Author

If you're wondering why anyone would care about column numbers...

I'm working on an exception server that can follow source-to-source mappings (e.g. when you minify JavaScript with Closure Compiler then run it in Node or the browser and an exception occurs, send the dump to the server and the server will find the line numbers and code fragments from your original source via a precomputed mapping that Closure Compiler can emit).

Without precise column numbers, those line numbers will be WAY off.

EDIT: one Python-to-JavaScript compiler also generates these source-to-source mappings, and later on so will CoffeeScript.

@TooTallNate
Copy link

Interesting use case!

@bnoordhuis
Copy link
Member

Possibly related to http://code.google.com/p/v8/issues/detail?id=764

@bnoordhuis
Copy link
Member

Closing. It's a V8 bug and it's been reported upstream.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants