cujojs / when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
Other
3.44k stars 396 forks source link

Consider adjustment to console calls for unhandledRejection #386

Closed guybedford closed 9 years ago

guybedford commented 9 years ago

I finally worked out the reason unhandledRejection errors still aren't showing for me.

I'm running the drop_console uglifyjs option to remove debug statements in the final file, and it is also removing the console.* statements from when.js in the process.

It's a big of an ask I know, as I should really just rewrite my build process, but perhaps it would be useful to other users to consider adjusting these statements to be non-droppable.

In https://github.com/cujojs/when/blob/master/lib/decorators/unhandledRejection.js, simply assigning console to a local variable first is enough to make this work and I've tested this successfully (var c = console).

briancavalier commented 9 years ago

@guybedford Ah, aliasing console does seem like the right thing. Since unhandled rejections are in the same class of things as uncaught exceptions, I think people will be surprised (as you were!) if uglify silences them.

I can push a branch for you to try out in a few mins.

briancavalier commented 9 years ago

Just pushed the prevent-console-removal branch. Can you try it out to make sure I got it right? If all is good, there's one other spot I need to update, and then I'll get this merged in and ready for a patch release. Thanks!

guybedford commented 9 years ago

@briancavalier thanks so much for the quick response. Yes I can confirm that is working great.

briancavalier commented 9 years ago

Great, thanks for confirming. I should be able to get a release out today.

briancavalier commented 9 years ago

@guybedford version 3.5.2 landed with this fix.

guybedford commented 9 years ago

Amazing, thanks for the speedy release.