Skip to content

Port Mojolicious 9.49 and stabilize Mojo::IOLoop #1115

Description

@fglock

Summary

Port Mojolicious 9.49 to the current PerlOnJava runtime. The historical CPAN report classifies the core distribution as SKIP, but it now installs and runs deeply enough that the remaining work is actionable and should be tracked as a high-priority compatibility effort.

This is strategically important: the CPAN dependency-priority tool reports 876 reverse runtime dependants, including 195 recent dependants. Mojolicious is also pure Perl, so the failures point to reusable PerlOnJava runtime fixes rather than an XS port.

Baseline

System Perl, with local loopback sockets available and the inherited NO_COLOR environment override removed:

All tests successful.
Files=109, Tests=4184
Result: PASS

PerlOnJava 5.44.1:

timeout 900 ./jcpan -t Mojolicious

Mojolicious installs and executes a substantial portion of the suite, but eventually hangs and is terminated by the 900-second bound. This should therefore replace the stale blanket SKIP classification with an actionable FAIL/TIMEOUT until the suite is stable.

Current failure clusters

The observed failures are concentrated in a few runtime areas rather than independent framework defects:

  1. Filehandle and selected-handle state

    • Bad file descriptor while reading templates and log files
    • empty destination paths in Mojo::Asset::Memory and file-copy operations
    • representative tests: t/mojo/file.t, t/mojo/log.t, t/mojo/template.t
  2. Listening sockets and poll integration

    • Can't create listen socket: Input/output error
    • affects daemon, IOLoop, file-download, user-agent, and application tests
    • representative tests: t/mojo/daemon.t, t/mojo/ioloop.t, t/mojo/reactor_poll.t
  3. Reactor and promise lifecycle

    • Can't call method "next_tick" on an undefined value in Mojo::Promise
    • is_running called on an undefined reactor
    • timer failure followed by non-termination
    • representative tests: t/mojo/promise.t, t/mojo/ioloop.t, application tests using Test::Mojo
  4. HTTP gzip decoding

    • compressed response body remains encoded or becomes empty
    • Content-Encoding and compressed Content-Length are retained
    • representative test: t/mojo/response.t
  5. Secondary diagnostic differences

    • template/loader exception text and line context differ from system Perl

Many foundational tests already pass, including parameters, paths, headers, PSGI, proxy handling, request CGI support, roles, signatures, and SSE. Developer-only TLS, prefork, subprocess, and online tests remain skipped by upstream defaults.

Proposed staged implementation

  1. Make synchronous Mojolicious Lite and PSGI applications reliable, using Mojo::Server::PSGI with the existing Netty PSGI handler where practical.
  2. Fix filehandle replacement/restoration and selected-handle behavior, with focused project-owned regression tests.
  3. Fix loopback listening sockets and IO::Poll integration.
  4. Stabilize IOLoop timers and promise scheduling; add a bounded reproducer for the current hang.
  5. Fix HTTP gzip response decoding.
  6. Extend coverage to the user agent and WebSockets.
  7. Document fork/prefork features as unsupported where they fundamentally require Perl fork.

The existing dev/modules/mojo_ioloop.md investigation should be updated rather than replaced. It documents earlier progress and root-cause candidates, including selected-handle restoration, reactor corruption, template diagnostics, and gzip handling.

Acceptance criteria

  • Add permanent focused regression tests for each confirmed PerlOnJava runtime defect; validate Perl-level behavior with system Perl first.
  • A bounded ./jcpan -t Mojolicious completes without hanging.
  • Core synchronous Lite/PSGI applications pass under both PerlOnJava backends where applicable.
  • IOLoop timer, listening-socket, promise, template/filehandle, and gzip-response tests pass.
  • Remaining upstream skips are limited to explicitly unsupported or opt-in facilities such as fork/prefork, external network, and optional TLS tests.
  • Update dev/modules/mojo_ioloop.md progress tracking and the CPAN compatibility classification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions