]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
search: async_mset: pass resource errors to callback
authorEric Wong <e@80x24.org>
Thu, 25 Apr 2024 21:31:45 +0000 (21:31 +0000)
committerEric Wong <e@80x24.org>
Sun, 28 Apr 2024 17:05:29 +0000 (17:05 +0000)
We need to be able to handle resource limitation errors in
public-facing daemons.

lib/PublicInbox/Search.pm

index 60d12dbf245f0fcb67797234da78be9feab007a8..b7732ae578e6187252a46dad2d5aed23d1b2f3e9 100644 (file)
@@ -469,8 +469,12 @@ sub async_mset {
        if ($XHC) { # unconditionally retrieving pct + rank for now
                xdb($self); # populate {nshards}
                my @margs = ($self->xh_args, xh_opt($opt));
-               my $rd = $XHC->mkreq(undef, 'mset', @margs, $qry_str);
-               PublicInbox::XhcMset->maybe_new($rd, $self, $cb, @args);
+               my $ret = eval {
+                       my $rd = $XHC->mkreq(undef, 'mset', @margs, $qry_str);
+                       PublicInbox::XhcMset->maybe_new($rd, $self, $cb, @args);
+               };
+               $cb->(@args, undef, $@) if $@;
+               $ret;
        } else { # synchronous
                my $mset = $self->mset($qry_str, $opt);
                $cb->(@args, $mset);