mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
99 stars 46 forks source link

Exceptions handle in PubSub #58

Closed bitnoize closed 5 years ago

bitnoize commented 5 years ago

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.

kraih commented 5 years ago

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.

kraih commented 5 years ago

This line is eating the exception.