Morbo server only works after continuous update

I am developing a web application with Mojolicious. The morbo development server is a wonderful thing that works great, but as soon as I start returning complex hashes on the stack and then building the web page, the morbo server starts acting funny. In my browser, if I go to one of those web pages that use a complex hash, the browser will tell me that the connection has been reset. I have to refresh about 10-12 times before the page loads.

For example:

The code below shows one of my application controllers. It just gets a json object from the AJAX request and then returns another json object. It works great, except that the browser needs to be updated up to thousands of times before it is loaded.

package MyApp::Controller::Library;
use Mojo::Base 'Mojolicious::Controller';

use Mojo::Asset::File;
use MyApp::Model::Generate;
use MyApp::Model::Database;
use MyApp::Model::IpDatabase;
use Mojo::JSON qw(decode_json);

# Receives a json object from an AJAX request and
# sends the necessary information back to be
# displayed in a table.
sub list_ajax_catch {
    my $self = shift;

    my $json  = $self->param('data');
    my $input = decode_json $json;

    $self->render(
        json => {
            "Object A" => {
                "name"        => "Object A Name",
                "description" => "A Description for Object A",
                "height"      => "10",
                "width"       => "5",
            }
        }
    );
}

1;

      

The problem is not limited to this instance. It looks like anytime there is a lot of processing on the server, the browser is resetting the issues. It doesn't matter what browser, I've tried Chrome, IE, Firefox and others (on multiple computers). It doesn't matter if I don't even send and receive data from the html to the application. All that seems to be causing it is if there is any handling in my web app, it is more than just templating, BUT if I run Hypnotoad everything is fine.

This example doesn't require a lot of processing, but it does call the browser to reset and as you can see, nothing is required to start or freeze. I thought the problem was with the timeout, but by default the timeout doesn't happen until 15 seconds, so it can't be.

+3


source to share


1 answer


I figured out the problem! This has been a problem for me for over a month now and I am very glad it works again. My problem was that when I started the morbo development server, I used the following command:

morbo -w ~/web_dev/my_app script/my_app

      



-w allows me to view the change directory so that I don't have to restart the application every time I change some of my JavaScript files. My problem was that the directory I was looking at also contained log files. So every time I visit the webpage, the logs change and the server restarts.

+2


source







All Articles