iced-coffeescript

why does iced coffeescript give warning: overused deferral when an exception is thrown


what does the "overused deferral" warning mean in iced coffeescript? It seems to happen when I throw an uncaught error in the code. How can I let the error bubble up as I need it be an uncaught error for unit testing. For instance, if my getByName method throws an error it bubbles up that iced coffeescript warning rather than bubbling up the exception.

await Profile.getByName p.uname, defer(err, existingUser)
return done new errors.DuplicateUserName(), 409 if existingUser isnt null
return done new Error("error in looking up user name " + err), 500 if err

Solution

  • This error is generated when a callback generated by defer is called more than once. In your case, it could be that Profile.getByName is calling its callback twice (or more). This warning almost always indicates an error in my experience.

    You can disable this warning if you create a callback from a Rendezvous and explicitly make it a "multi" callback. Otherwise, it only makes sense to have the return from defer give you a one-shot callback.

    More info here: https://github.com/maxtaco/coffee-script/blob/iced/iced.md#icedrendezvousidimultidefer-slots

    A small note on terminology: in IcedCoffeeScript, a callback generated by defer is known as a "deferral" in error messages and the documentation.