diff --git a/lib/AnyEvent/NSQ/Reader.pm b/lib/AnyEvent/NSQ/Reader.pm index a70043a..6cfed56 100644 --- a/lib/AnyEvent/NSQ/Reader.pm +++ b/lib/AnyEvent/NSQ/Reader.pm @@ -7,6 +7,7 @@ package AnyEvent::NSQ::Reader; use strict; use warnings; use Carp 'croak'; +use Scalar::Util qw( weaken ); use parent 'AnyEvent::NSQ::Client'; @@ -58,6 +59,7 @@ sub _identified { ## Keep the connection in the registry in case the user ## wants to issue FIN/REQs inside the callback $self->{routing}->{$msg->{message_id}} = $conn; + weaken( $self->{routing}->{$msg->{message_id}} ); my $action = $self->{message_cb}->($self, $msg);