Skip Menu |
 

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 89623
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: jettero [...] cpan.org
Cc: victor [...] vsespb.ru
AdminCc:

Bug Information
Severity: (no value)
Broken in: 6.05
Fixed in: (no value)



Subject: callback (aka :content_cb) function hides basic typos and assorted runtime errors
I'm not sure if this belongs in LWP::.*Protocol::http or in HTTP::Message or somewhere. I went source diving, but it appears to be beyond my skill level to find the eval{} or other capture. Basically the problem is that this code will produce no errors, the rest of the callback will not fire, and the developer will be left wondering what the hell happened for like an hour and a half -- durations will vary. $ua->get("blarg", ':content_cb' => sub { my $oops; $oops->broken_but_silent }); I attached a small demo of this, though, I think it was already pretty clear. Basically any runtime error (fatal typos die() croak() or other) will disappear into the æther. I tried this on a couple machines, but if it's unique to ubuntu, I wouldn't be super shocked. I've tried on 13.10 and 13.04, but I suspect it's really in the libwww-perl package somewhere and not related to cannonical perl patches. -- If riding in an airplane is flying, then riding in a boat is swimming. 116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.
Subject: small.pl
Download small.pl
text/x-perl 485b
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my ($worked, $borked) = ("",""); # NOTE: clearly a bad typo in the second one... no error, no nuttin' :( # broken in my LWP 6.05 perl5 (revision 5 version 14 subversion 2) $ua->get("http://ip.kfr.me", ':content_cb' => sub { $worked .= shift }); $ua->get("http://ip.kfr.me", ':content_cb' => sub { my $o; $o->test; $borked .= shift }); print "worked: $worked"; print "borked: $borked\n";
Download (untitled) / with headers
text/plain 1.8k
If you change code this way my $resp = $ua->get("http://ip.kfr.me", ':content_cb' => sub { my $o; $o->test; $borked .= shift }); print $resp->dump; you'll see: HTTP/1.1 200 OK Connection: close Date: Wed, 23 Oct 2013 19:40:04 GMT Server: Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.1e Content-Type: text/plain Client-Aborted: die Client-Date: Wed, 23 Oct 2013 19:40:04 GMT Client-Peer: 69.174.176.168:80 Client-Response-Num: 1 Client-Transfer-Encoding: chunked X-Died: Can't call method "test" on an undefined value at 1.pl line 15. notice "Client-Aborted: die", and "X-Died:" I think this is documented: === The callback can abort the request by invoking die(). The exception message will show up as the "X-Died" header field in the response returned by the get() function. === However, that's sad that this for response is_success() still returns TRUE, and response code is 200 (not sure here). On Sat Oct 19 16:46:51 2013, JETTERO wrote: Show quoted text
> I'm not sure if this belongs in LWP::.*Protocol::http or in > HTTP::Message or somewhere. I went source diving, but it appears to > be beyond my skill level to find the eval{} or other capture. > > Basically the problem is that this code will produce no errors, the > rest of the callback will not fire, and the developer will be left > wondering what the hell happened for like an hour and a half -- > durations will vary. > > $ua->get("blarg", ':content_cb' => sub { my $oops; $oops-
> >broken_but_silent });
> > I attached a small demo of this, though, I think it was already pretty > clear. Basically any runtime error (fatal typos die() croak() or > other) will disappear into the æther. I tried this on a couple > machines, but if it's unique to ubuntu, I wouldn't be super shocked. > I've tried on 13.10 and 13.04, but I suspect it's really in the > libwww-perl package somewhere and not related to cannonical perl > patches.
Download (untitled) / with headers
text/plain 315b
Oh, my mistake then. If that's the documented behavior, I suppose it's not a bug at all. Seems not quite right to me though. I apparently just disagree with the implementation. -- If riding in an airplane is flying, then riding in a boat is swimming. 116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.
Download (untitled) / with headers
text/plain 450b
On 2013-10-23 21:52:02, JETTERO wrote: Show quoted text
> Oh, my mistake then. If that's the documented behavior, I suppose > it's not a bug at all. Seems not quite right to me though. I > apparently just disagree with the implementation.
X-Died is not documented for all error cases, and I also agree that is_success() should not return true in these cases. See https://rt.cpan.org/Ticket/Display.html?id=101990 for a bug report which explicitly expresses this.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.