gulp-jspm icon indicating copy to clipboard operation
gulp-jspm copied to clipboard

Error: cannot enable long stack traces after promises have been created.

Open gersongoulart opened this issue 9 years ago • 5 comments

@brillout thank you for gulp-jspm. I've been using it for a little while and has been great so far!

Today I updated all packages in my complex build system where some of the gulp plugins I use also depend on Bluebird. Turns out the build is breaking in this line: https://github.com/brillout/gulp-jspm/blob/master/index.js#L6

Apparently Promise.longStackTraces affects Bluebird globally, and since promises have already been instantiated in earlier parts of the build, I get this error:

Error: cannot enable long stack traces after promises have been created. See http://goo.gl/MqrFmX

Perhaps the Promise.longStackTraces(); call could be wrapped in a try/catch block to avoid conflicts? (Doing that locally suppressed the error while allowing my build to complete successfully even if without long stack traces).

gersongoulart avatar Jul 27 '16 22:07 gersongoulart

Actually a Library shouldn't set longStackTraces but I'm not sure how to then give the user the possibility to enable it and I'm not sure if the performance penalty is that bad to justify having the user to explicitly enable it. But that's another topic.

As for your issue; would using Promise.config help? See http://bluebirdjs.com/docs/api/promise.config.html. I don't know if it also throws an exception if called another time. The doc doesn't seem to mention this.

brillout avatar Jul 28 '16 14:07 brillout

Yes, I also tried the config solution and it did not work either (I got the exact same error, hence I believe either method does exactly the same to Bluebird internally).

I suggested the use of try/catch because that would keep longStackTraces around unless there's another Library already using Bluebird's Promise, allowing the user to set that config manually wouldn't help in this situation. I actually could not think of other solution to keep longStackTraces. The alternative to using try/catch would be to remove longStackTraces. :P

gersongoulart avatar Jul 28 '16 16:07 gersongoulart

I'm temporarily publishing the npm package gulp-jspm-fix to avoid having our whole team unable to build our app... Let me know if you'd like me to send out a PR with this simple solution (removing longStackTraces).

gersongoulart avatar Jul 28 '16 18:07 gersongoulart

Yea, a PR with the try catch solution would be awesome! 👍

brillout avatar Aug 29 '16 07:08 brillout

@brillout I'm sorry it took me so long to get back to this... I somehow manage to loose track of the issue :P

Hopefully the PR above will please you.

gersongoulart avatar Nov 08 '16 02:11 gersongoulart