Currently can't get source maps working correctly with Promise.method and Browserify.
var Promise = require('bluebird')
Promise.longStackTraces()
var foo = Promise.method(function() {
throw new Error("BLAH")
return 200
})
foo()
Stack trace:
Possibly unhandled Error: BLAH
at http://localhost:8000/js/bundle.js:8:11
at tryCatch1 (http://localhost:8000/js/bundle.js:5082:21)
at Promise$_method (http://localhost:8000/js/bundle.js:2184:25)
at Object../tests/cocoon-app.js.bluebird (http://localhost:8000/js/bundle.js:13:1)
at s (http://localhost:8000/js/bundle.js:1:254)
at e (http://localhost:8000/js/bundle.js:1:425)
at http://localhost:8000/js/bundle.js:1:443
The error source-maps correctly without the Promise.method wrapper. Noticing the same with Promise.promisify.
Without promise.method in that code there are no promises involved in the first place. The stack trace builder works directly with the .stack property of errors, it has no knowledge of source maps
Hmm so there is basically no way that source maps will work with promises in bundles?
Is there some sort of bundler transform that could be developed to solve this? The full path to the source file is known during AST transforms. I'd be willing to contribute but I don't know much about bluebirds internal error handling.
@mattdesl a pull request would definitely be interesting. You should check out how Bluebird stitches stack traces.
Managed to get a bit further thanks to source-map-support.
npm install source-map-support --save
Then in your entry point: (make sure you bundle with --debug)
require('source-map-support').install()
This gives me the following trace:
Possibly unhandled Error: BLAH
at Base.module.exports.require.create (src/sections/TestGrid.js:20:1)
at tryCatch1 (node_modules/bluebird/js/main/util.js:45:1)
at Promise$_method (node_modules/bluebird/js/main/promise.js:237:1)
at promise (node_modules/transitions/base.js:6:1)
at tryCatch1 (node_modules/bluebird/js/main/util.js:45:1)
at Promise$_callHandler [as _callHandler] (node_modules/bluebird/js/main/promise.js:659:1)
at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (node_modules/bluebird/js/main/promise.js:673:1)
at Promise$_settlePromiseAt [as _settlePromiseAt] (node_modules/bluebird/js/main/promise.js:836:1)
at Promise$_settlePromises [as _settlePromises] (node_modules/bluebird/js/main/promise.js:979:1)
at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (node_modules/bluebird/js/main/async.js:78:1)
Now I just need to figure out why the URLs are not clickable (so that it opens the file in question). Any ideas? Maybe something to do with source root...
Are you using longStackTraces() ?
On Sat, Oct 25, 2014 at 21:05 Matt DesLauriers [email protected]
wrote:
Managed to get a bit further thanks to source-map-support
https://github.com/evanw/node-source-map-support.npm install source-map-support --save
Then in your entry point: (make sure you bundle with --debug)
require('source-map-support').install()
This gives me the following trace:
Possibly unhandled Error: BLAH
at Base.module.exports.require.create (src/sections/TestGrid.js:20:1)
at tryCatch1 (node_modules/bluebird/js/main/util.js:45:1)
at Promise$_method (node_modules/bluebird/js/main/promise.js:237:1)
at promise (node_modules/transitions/base.js:6:1)
at tryCatch1 (node_modules/bluebird/js/main/util.js:45:1)
at Promise$_callHandler as _callHandler
at Promise$_settlePromiseFromHandler as _settlePromiseFromHandler
at Promise$_settlePromiseAt as _settlePromiseAt
at Promise$_settlePromises as _settlePromises
at Async$_consumeFunctionBuffer as _consumeFunctionBufferNow I just need to figure out why the URLs are not clickable (so that it
opens the file in question). Any ideas? Maybe something to do with source
root...—
Reply to this email directly or view it on GitHub
https://github.com/petkaantonov/bluebird/issues/363#issuecomment-60491306
.
@benjamingr Just tested with and without, no difference, but probably because of #359 (errors are coming from functions wrapped with Promise.method).
Interesting that the following works:
console.log('http://localhost:8000/js/bundle.js:25:5')
Clicking it in console will open the file and line number in DevTools. But it can't find the src folder that has my original JS.. So this doesn't work:
console.log('http://localhost:8000/js/src/framework/index.js:25:5')
Even though it appears in Source panel...

@mattdesl - so it looks like the source map URL isn't being turned into a link because source-map-support isn't including the page origin in the stack trace.
It's generating:
Unhandled rejection Error: oops!
at Route.willTransitionTo [as onEnter] (components/outcomes-component.js:29:21)
Instead of:
Unhandled rejection Error: oops!
at Route.willTransitionTo [as onEnter] (http://localhost:8080/components/outcomes-component.js:29:21)
A handy work around is to:
components/outcomes-component.js:29:21) CMD+P, then paste in the location and hit ENTERNot as nice as a link, but better than manually hunting for the file/line offset.
I have the same issue, I can't make sourcemaps work, that's make debugging such a pain ... Bluebird is a nice library but I don't get why it modifies the way unhandled errors are displayed ...
Was this ever fixed? I'm having the same trouble with Bluebird v3.1.1
Most helpful comment
Was this ever fixed? I'm having the same trouble with Bluebird v3.1.1