Raven.js not pointing to correct file for syntax errors

Hi all,

I have noticed that the stack trace printed by Raven doesn’t match the trace that is printed by pure nodejs by default, which can make it harder to debug some errors.

Example:

My project includes a module that contains an typo. In this case, it’s a malformed object (no comma between attributes)

When I try to load the application, nodejs will give me the following error:

2017-11-15T19:12:48.48006 /hdenv/code/cloudstorage/lib/qbo.js:481
2017-11-15T19:12:48.48015 ‘cat’: 'test’
2017-11-15T19:12:48.48021 ^^^^^
2017-11-15T19:12:48.48026
2017-11-15T19:12:48.48036 SyntaxError: Unexpected string
2017-11-15T19:12:48.48045 at exports.runInThisContext (vm.js:53:16)
2017-11-15T19:12:48.48054 at Module._compile (module.js:373:25)
2017-11-15T19:12:48.48060 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:48.48065 at Module.load (module.js:343:32)
2017-11-15T19:12:48.48066 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:48.48071 at Module.require (module.js:353:17)
2017-11-15T19:12:48.48078 at require (internal/module.js:12:17)
2017-11-15T19:12:48.48081 at Object. (/hdenv/code/cloudstorage/index.js:5:37)
2017-11-15T19:12:48.48086 at Module._compile (module.js:409:26)
2017-11-15T19:12:48.48090 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:48.48095 at Module.load (module.js:343:32)
2017-11-15T19:12:48.48100 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:48.48110 at Module.require (module.js:353:17)
2017-11-15T19:12:48.48114 at require (internal/module.js:12:17)
2017-11-15T19:12:48.48129 at Object. (/hdenv/code/webapp/routes/main.js:7:24)
2017-11-15T19:12:48.48133 at Module._compile (module.js:409:26)

When I enable Raven for my application, the stack trace is:

2017-11-15T19:12:58.53051 SyntaxError: Unexpected string
2017-11-15T19:12:58.53072 at exports.runInThisContext (vm.js:53:16)
2017-11-15T19:12:58.53089 at Module._compile (module.js:373:25)
2017-11-15T19:12:58.53162 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:58.53180 at Module.load (module.js:343:32)
2017-11-15T19:12:58.53200 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:58.53221 at Function._load (/hdenv/code/webapp/node_modules/raven/lib/instrumentation/instrumentor.js:33:35)
2017-11-15T19:12:58.53243 at Module.require (module.js:353:17)
2017-11-15T19:12:58.53264 at require (internal/module.js:12:17)
2017-11-15T19:12:58.53282 at Object. (/hdenv/code/cloudstorage/index.js:5:37)
2017-11-15T19:12:58.53300 at Module._compile (module.js:409:26)
2017-11-15T19:12:58.53319 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:58.53337 at Module.load (module.js:343:32)
2017-11-15T19:12:58.53356 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:58.53367 at Function._load (/hdenv/code/webapp/node_modules/raven/lib/instrumentation/instrumentor.js:33:35)
2017-11-15T19:12:58.53381 at Module.require (module.js:353:17)
2017-11-15T19:12:58.53398 at require (internal/module.js:12:17)
2017-11-15T19:12:58.53413 at Object. (/hdenv/code/webapp/routes/main.js:7:24)
2017-11-15T19:12:58.53425 at Module._compile (module.js:409:26)
2017-11-15T19:12:58.53437 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:58.53448 at Module.load (module.js:343:32)
2017-11-15T19:12:58.53458 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:58.53467 at Function._load (/hdenv/code/webapp/node_modules/raven/lib/instrumentation/instrumentor.js:33:35)
2017-11-15T19:12:58.53479 at Module.require (module.js:353:17)
2017-11-15T19:12:58.53491 at require (internal/module.js:12:17)
2017-11-15T19:12:58.53503 at Object. (/hdenv/code/webapp/webapp.js:295:1)
2017-11-15T19:12:58.53515 at Module._compile (module.js:409:26)
2017-11-15T19:12:58.53527 at Object.Module._extensions…js (module.js:416:10)
2017-11-15T19:12:58.53542 at Module.load (module.js:343:32)
2017-11-15T19:12:58.53555 at Function.Module._load (module.js:300:12)
2017-11-15T19:12:58.53568 at Function.Module.runMain (module.js:441:10)
2017-11-15T19:12:58.53579 at startup (node.js:139:18)
2017-11-15T19:12:58.53590 at node.js:990:3

This output is much harder to debug because it doesn’t actually point to the line (let alone file) where the SyntaxError occurs.

This this a bug with Raven.js or is it the result of something not being configured properly?