Closed bitnoize closed 5 years ago
use Mojo::Base -strict; use Mojo::Pg;
my $pg = Mojo::Pg->new("postgresql://localhost/test"); my $pubsub = $pg->pubsub;
$pubsub->listen(test => sub { my ($pubsub, $payload) = @_;
say $payload; # message received in any case die "Shit happens"; # exception happens only with $pubsub->notify });
$pubsub->notify(test => "test");
Mojo::IOLoop->start;
Die exception happens in any case, even if message send via NOTIFY test, 'test' from psql console
Die exception happens only if script sends self message via $pubsub->notify
Seems this is a bug.
Yes, that's a bug. We have to do an eval internally at a certain point because $dbh->pg_notifies will fail sometimes. That can probably be handled better.
eval
$dbh->pg_notifies
This line is eating the exception.
Steps to reproduce the behavior
use Mojo::Base -strict; use Mojo::Pg;
my $pg = Mojo::Pg->new("postgresql://localhost/test"); my $pubsub = $pg->pubsub;
$pubsub->listen(test => sub { my ($pubsub, $payload) = @_;
say $payload; # message received in any case die "Shit happens"; # exception happens only with $pubsub->notify });
Without this command, die exception from listen callback not happens
$pubsub->notify(test => "test");
Mojo::IOLoop->start;
Expected behavior
Die exception happens in any case, even if message send via NOTIFY test, 'test' from psql console
Actual behavior
Die exception happens only if script sends self message via $pubsub->notify
Seems this is a bug.