Here’s a good one that took a few hours to debug.

TLDR

Lesson of the day: do not return out of a wisper ‘on’ block — doing so will

terminate early and other listeners will not fire. Because a block behaves like a Proc — a return out of a block will exit the calling context.

Explanation

When we subscribe a controller with an anonymous ‘on’ block like this

Because the block is treated like a “Proc” in Ruby, in the sense that returning out of it actually returns outside the parent caller, this causes the Wisper loop that is going over all the other listeners to abort. That means if you have any global listeners subscribed, they may not fire.

This bug is very difficult to catch because if you test this without invoking the controller code that subscribes, everything seems fine. However in production and regular control flow, the controller’s early return screws things up.

Further Proof

Yan Pritzker

CTO, Reverb.om

@skwp