tempus71
tempus71

Reputation: 175

mojolicious need all the time out time for load a page on production with hypnotoad

There is one page on my Mojolicious project that loads correctly but then the connections doesn't finish until arrive to the timeout time.

I got the problem only with hypnotoad on production server.

I couldn't replicate the problem on development.

I have been one day investigating the issue due the page was doing and api request to an external service.

Initially I was thinking it was due to some Mojo::UserAgent problem and I have been trying multiple combinations of Promise and IOLoop and anyone was working.

the code simplified is:

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();

}

I don't share template code because isn't necessary.

The page and template load correctly but the browser, chrome, stay loading until arrive to the timeout. (15s default)

Upvotes: 2

Views: 125

Answers (1)

tempus71
tempus71

Reputation: 175

The reason of the problem is that I was using a reserved stash word 'status'.

The solution is change the name of the variable on stash and in the template:

   $s->stash(
        namePlan => $plan->name,
        monthDuration => $plan->monthDuration,
        amount => $plan->amount,
        end => $subscription->end,

        subStatus => $subscription->status,

        signupDate => $customer->signupDate,
        endTrial => $customer->endTrial,
        diffTrial => $customer->diffTrial,
        trialDays => $customer->trialDays,
        startSubscription => $subscription->start,
        discount => $plan->discount,
        newsletter => $newsletter,
    );

Upvotes: 2

Related Questions