Skip Menu |

This queue is for tickets about the Firefox-Marionette CPAN distribution.

Report information
The Basics
Id: 131173
Status: resolved
Priority: 0/
Queue: Firefox-Marionette

People
Owner: Nobody in particular
Requestors: jsd [...] av8n.com
Cc:
AdminCc:

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



Subject: defend against sigpipe in Firefox::Marionette
Date: Fri, 13 Dec 2019 13:21:08 -0700
To: bug-firefox-marionette [...] rt.cpan.org
From: John Denker <jsd [...] av8n.com>
Hi -- Desired behavior: *) Library modules should never terminate the process. If need be, they can throw exceptions, but these should be catchable. *) If an operation produces an error message, repeating the operation should produce the same error message. Observed behavior: If the browser quits, then: 1) The next Marionette operation will throw an exception (((Firefox killed by a USR1 signal (10) in my/script at line 1002))) This is good behavior. The exception can be caught with eval {....} in the usual way. 2) The operation after that causes the entire process to be terminated by a SIGPIPE. Plain eval {....} does not catch this. This is a royal pain. The penalty for operating on a dead browser should not be losing all your work. =========== *) As a workaround, the user could catch sigpipe. $SIG{PIPE} = sub { Carp::croak "Caught a sigpipe: $!" }; However, this is not mentioned in the Firefox::Marionette documentation, and it unnecessarily increases user workload. It is not consistent with the overall design of the package. *) As an even worse workaround, the user could guard every Marionette operation with $driver->alive(), but that is even more workload for the user. ======================================================== SPECIFIC CONSTRUCTIVE SUGGESTION: Defend against sigpipe. The following patch should be more-or-less self-explanatory. It makes things more consistent and more convenient for everybody. In particular, it means repeated operations all produce the same error message. --- Marionette.pm#1 2019-12-13 02:32:45.949508275 -0700 +++ Marionette.pm 2019-12-13 04:18:28.078483824 -0700 @@ -29,6 +29,7 @@ use Carp(); use Config; use base qw(Exporter); +use Scalar::Util qw(openhandle); BEGIN { if ( $OSNAME eq 'MSWin32' ) { @@ -1582,6 +1583,10 @@ } } } +# Close the handle, because writing to a broken pipe is fatal, +# but writing to a closed handle is not. Also, openhandle() +# detects closed, but does not detect broken. + close($self->{_socket}) if defined $self->{_child_error}; return; } @@ -4600,7 +4605,11 @@ if ( $self->_debug() ) { warn ">> $length:$json\n"; } - my $result = syswrite $self->_socket(), "$length:$json"; + my $result; +# Validate the handle, to avoid an annoying message on STDERR: + if (openhandle $self->_socket()) { + $result = syswrite $self->_socket(), "$length:$json"; + } if ( !defined $result ) { my $socket_error = $EXTENDED_OS_ERROR; if ( $self->alive() ) {
Thanks for the report. 0.86 has just been uploaded to address this.
Subject: Re: [rt.cpan.org #131173] Resolved: defend against sigpipe in Firefox::Marionette
Date: Sat, 14 Dec 2019 09:09:27 -0700
To: bug-Firefox-Marionette [...] rt.cpan.org
From: John Denker <jsd [...] av8n.com>
Question: How do I obtain the new version 0.86? cpan is telling me that 0.85 is "up to date". I assume this is a mirroring issue. Should I just wait? It's been more than a day since the update was reportedly pushed. How long should it take? On 12/14/19 3:28 AM, David Dick via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=131173 > > > According to our records, your request has been resolved. If you have any > further questions or concerns, please respond to this message.
On 12/13/19 8:54 PM, David Dick via RT wrote: Show quoted text
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=131173 > >> >> Thanks for the report. 0.86 has just been uploaded to address this.