【发布时间】:2019-04-23 18:42:10
【问题描述】:
我的 Mojolicious 项目中有一个页面可以正确加载,但连接直到超时时间才完成。
我只在生产服务器上遇到了 hypnotoad 的问题。
我无法在开发中复制问题。
由于页面正在执行以及对外部服务的 api 请求,我一直在调查该问题。
最初我认为这是由于一些 Mojo::UserAgent 问题,我一直在尝试 Promise 和 IOLoop 的多种组合,并且任何人都在工作。
代码简化为:
sub show {
my $s = shift;
my $customer = Model::Customers->new();
$customer->id( $s->session('id') );
$customer->get();
my $subscription = Model::Customers::Subscriptions->new();
$subscription->id( $s->session('id') );
$subscription->get();
my $plan = Model::Plans->new();
$plan->id( $subscription->idPlan );
$plan->get;
$s->stash(
namePlan => $plan->name,
monthDuration => $plan->monthDuration,
amount => $plan->amount,
end => $subscription->end,
status => $subscription->status,
signupDate => $customer->signupDate,
endTrial => $customer->endTrial,
diffTrial => $customer->diffTrial,
trialDays => $customer->trialDays,
startSubscription => $subscription->start,
discount => $plan->discount,
newsletter => $newsletter,
);
$s->render();
}
我不共享模板代码,因为没有必要。
页面和模板加载正确,但浏览器 chrome 会一直加载,直到超时。 (默认 15 秒)
【问题讨论】:
标签: perl mojolicious