Hello
I'm a bit puzzled by the result I get from this test case:
============
use Mojo::Base -strict;
use Test::More;
use Mojo::IOLoop;
my $err;
my $sub = Mojo::IOLoop->subprocess(
sub { exit 55 },
sub { my $self = shift; $err = shift; Mojo::IOLoop->stop }
);
Mojo::IOLoop->start;
cmp_ok $sub->exit_code, '==', 55, 'exit code';
is $err, '', 'no exception';
done_testing;
============
The second test (testing the contents of $err) fails with the error message "malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)")". It gives me a line number as follows: "~/opt/perl-5.30.2/lib/site_perl/5.30.2/Mojo/JSON.pm line 31". The context in that file around line 31 is:
============
# Replace pure-Perl fallbacks if Cpanel::JSON::XS is available
if (JSON_XS) {
my $BINARY = Cpanel::JSON::XS->new->utf8;
my $TEXT = Cpanel::JSON::XS->new;
$_->canonical->allow_nonref->allow_unknown->allow_blessed->convert_blessed->stringify_infnan->escape_slash
->allow_dupkeys
for $BINARY, $TEXT;
monkey_patch __PACKAGE__, 'encode_json', sub { $BINARY->encode($_[0]) };
monkey_patch __PACKAGE__, 'decode_json', sub { $BINARY->decode($_[0]) };
monkey_patch __PACKAGE__, 'to_json', sub { $TEXT->encode($_[0]) };
monkey_patch __PACKAGE__, 'from_json', sub { $TEXT->decode($_[0]) };
}
============
Now I fail to understand why I'm getting this particular error, considering I'm not using any JSON functionality in this script. Looking at the file where the error originates doesn't give me any clues. I'm a bit lost here. Could anyone shed some light on this?
I'm using the latest Mojolicious:
CORE
Perl (v5.30.2, linux)
Mojolicious (8.57, Supervillain)
OPTIONAL
Cpanel::JSON::XS 4.09+ (4.19)
EV 4.32+ (4.33)
IO::Socket::Socks 0.64+ (0.74)
IO::Socket::SSL 2.009+ (2.068)
Net::DNS::Native 0.15+ (0.22)
Role::Tiny 2.000001+ (2.001004)
Future::AsyncAwait 0.36+ (0.40)
This version is up to date, have fun!
============
Kind regards
Edward