Subject: | $c->finalize_headers gets called multiple times |
I have had the following in my Cat app for a long time:
sub MyApp::finalize_headers {
my $c = shift;
# ...
# log request and response status to database
# disconnect from DB
return $c->next::method;
}
Recently I upgraded Catalyst to 5.90014 and found that this gets called
twice, which caused an erroneous duplicate attempt to log the request,
which would immediately fall over because the DBH was already
disconnected, causing Cat to die inside the engine.
Unfortunately I did not make a note of which exact Catalyst version I
was using before, so I cannot say exactly which release broke it. But I
know I was on a 5.9 series release before.
I talked with t0m on IRC who instructed me to add
return if $c->res->finalized_headers;
to the top of the method, and with that I’m back in business. But this
was not necessary before; t0m said it is a regression. He asked me to
file a ticket, so here it is.