Skip to content
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

Noder should preserve stack traces when re-throwing exceptions from loaded scripts #26

Open
PK1A opened this issue Sep 22, 2014 · 1 comment

Comments

@PK1A
Copy link

PK1A commented Sep 22, 2014

As of today noder-js will catch and re-throw exceptions originating from loaded scripts. But when re-throwing in exception we are loosing the original stack trace which contains information paramount to the effective application debugging.

Consider this simple example:

which simply throws:

Uncaught TypeError: Cannot read property '+1:oid' of null

without giving me the line number / file name (at least in Chrome, it might be browser dependent). With a message as the only info it is really hard to debug effectively, especially bigger applications.

While what I would expect is this:

"TypeError: Cannot read property '+1:oid' of null
at Object.klass.createObjectObserver (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:3617:30)
at Object.klass.createExpressionObservers (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:3605:34)
at Object.klass.createNodeInstance (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:2074:25)
at Object.klass.createNodeInstance (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:2086:65)
at Object.klass.init (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:3559:45)
at Object.klass.$constructor (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:3524:26)
at Object.klass.process (http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:5938:28)
at Object.exports.template.f as template
at Object.arguments.(anonymous function).res (eval at (http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1313:19), :12:16)
at Object.contextProto.moduleExecuteSync (http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1185:70)"

I'm painfully aware of the fact that exceptions / stack traces are in a lamentable state in JavaScript but IMO we need to improve the situation here as people might loose way to much time on debugging.

@divdavem
Copy link
Member

Hi @PK1A,
Thank you for reporting this issue.

I have tried to reproduce this issue with Chrome with this plunk (which uses hashspace and noder-js):

<script>
var something = null;
something[0] = 10; // will throw an exception 
</script>

And I get the following error in the console, which contains the full expected stack:

stack

Maybe you tested something a bit different?

Also, as you said, it seems to be browser-dependent: Firefox (with Firebug) only displays the last function call in the stack:

stack-ff

I am not sure if and how we can fix this. Of course, we have the stack property on the exception, but it is not as convenient as having the browser correctly displaying the stack (and being able to click on each item in the stack to view the source code).

For info, the stack property on Firefox looks like this:

"module.exports.$set@http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:229:1
module.exports@http://hashspace.ariatemplates.com/dist/0.0.5-SNAPSHOT/hashspace-noder.js:315:13
arguments[1].res@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js line 1313 > eval:14:1
contextProto.moduleExecuteSync@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1185:17
contextProto.moduleRequire@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1198:13
bind$module/<@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:107:13
arguments[1].res@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js line 1313 > eval:5:11
contextProto.moduleExecuteSync@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1185:17
contextProto.moduleExecute/<@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:1226:17
callback@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:162:37
syncCall@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:67:17
syncCalls@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:74:17
asyncCall$module.nextTickCalls/<@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:97:25
syncCall@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:67:17
syncCalls@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:74:17
syncTick@http://noder-js.ariatemplates.com/dist/v1.6.0/noder.dev.js:80:17
"

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

No branches or pull requests

2 participants