Skip to content

Retrying just puts load on API, so just fail #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/MetaCPAN/Web/Model/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ sub request {
);

my $req_p = $self->client->do_request( request => $request );
$req_p = $req_p->catch( sub {

# retry once
$self->client->do_request( request => $request );
} );
# Do not retry - if the API is loaded/slow then this just makes it worse.
# $req_p = $req_p->catch( sub {

# # retry once
# $self->client->do_request( request => $request );
# } );
$req_p->transform(
done => sub {
my $response = shift;
Expand Down
35 changes: 18 additions & 17 deletions t/controller/feed.t
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,24 @@ subtest 'get correct author release data format' => sub {
is( $entry->[0]->{author}, 'OALDERS', 'get correct author name' );
};

## We are not doing retries as if API is loaded we do not want to retry
# do this last so the override_api_response only affects this
my $how_many = 0;
override_api_response(
if => sub { !$how_many++ }, # fail only once
sub { Future->fail('Error'); },
);
test_psgi app, sub {
my $cb = shift;
subtest 'retry on transient failure' => sub {
ok( my $res = $cb->( GET '/recent.rss' ) );
is( $res->code, 200, 'code 200' );
is(
$res->header('content-type'),
'application/rss+xml; charset=UTF-8',
'Content-type is application/rss+xml'
);
};
};
# my $how_many = 0;
# override_api_response(
# if => sub { !$how_many++ }, # fail only once
# sub { Future->fail('Error'); },
# );
# test_psgi app, sub {
# my $cb = shift;
# subtest 'retry on transient failure' => sub {
# ok( my $res = $cb->( GET '/recent.rss' ) );
# is( $res->code, 200, 'code 200' );
# is(
# $res->header('content-type'),
# 'application/rss+xml; charset=UTF-8',
# 'Content-type is application/rss+xml'
# );
# };
# };

done_testing;