mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 577 forks source link

Morbo issues with Mojolicious 9.34 (change in Mojo/Server.pm) #2110

Closed daleif closed 1 year ago

daleif commented 1 year ago

Steps to reproduce the behavior

Inspired by the example in #2094

use v5.34;
use Mojolicious::Lite -signatures;
$test;
app->start;

Then run with morbo

Expected behavior

Something like

Web application available at http://127.0.0.1:3000
Can't load application from file "path to script": Global symbol "$test" requires explicit package name (did you forget to declare "my $test"?) at "path to script" line 3.
Compilation failed in require at (eval 93) line 1.

Actual behavior

Instead I get

Web application available at http://127.0.0.1:3000
Can't load application from file "path to script": "path to script" did not return a true value at path/lib/perl5/Mojo/Server.pm line 59.

Which makes debugging ones own mistakes rather hard.

Note that the problem is related to #2097 which changed

    my $app = eval "package Mojo::Server::Sandbox::@{[md5_sum $path]}; require \$path";

in Mojo/Server.pm into

    my $app = eval "package Mojo::Server::Sandbox::@{[md5_sum $path]}; do \$path";

(plus some extra checks).

Manually changing do back into require makes morbo behave like normal.

daleif commented 1 year ago

I'm wondering if it should make sense to run both the do and the require version. Such that the latter is run if the first did not return a true value.