mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework

Home Page:https://mojolicious.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UserAgent triggers preliminary render

yuriy-zhilovets2 opened this issue · comments

  • Mojolicious version: 9.32
  • Perl version: 5.24, also 5.28
  • Operating system: Linux Debian 10

Steps to reproduce the behavior

use Modern::Perl;
use Mojo::Base -strict, -async_await;
use Mojolicious::Lite;

get "/" => async sub
{
  my $c = shift;
  await app->ua->get_p("https://mojolicious.org");
  $c->redirect_to("some-page");
};

app->start;

Expected behavior

[2023-05-15 16:46:51.98997] [18092] [trace] [yeAtEA7AkTPe] GET "/"
[2023-05-15 16:46:51.99027] [18092] [trace] [yeAtEA7AkTPe] Routing to a callback
[2023-05-15 16:46:52.51878] [18092] [trace] [yeAtEA7AkTPe] 302 Found (0.528797s, 1.891/s)

Actual behavior

[2023-05-15 16:46:51.98997] [18092] [trace] [yeAtEA7AkTPe] GET "/"
[2023-05-15 16:46:51.99027] [18092] [trace] [yeAtEA7AkTPe] Routing to a callback
[2023-05-15 16:46:51.99115] [18092] [trace] [yeAtEA7AkTPe] Template ".html.ep" not found
[2023-05-15 16:46:51.99122] [18092] [trace] [yeAtEA7AkTPe] Nothing has been rendered, expecting delayed response

[2023-05-15 16:46:52.51878] [18092] [trace] [yeAtEA7AkTPe] 302 Found (0.528797s, 1.891/s)

Async call of await get_p tries to render a page preliminarily.
await Mojo::UserAgent->new->get_p(...) works in the same way.

Replacing of UserAgent call for e.g. Mojo::Promise->resolve() works fine.