This sucks.

MovableType is great, but...

Every time that api.google.com times out (like now), MT decides that it can't build pages anymore. Therefore, I cannot post.

500 Can't connect to api.google.com:80 (connect: timeout) at /home/jzawodn/public_html/mt/lib/MT/Template/Context.pm line 1749

I know that's because I use the Google API search results in my pages, but shouldn't it just timeout and gracefully continue as if the call returned no results?

Yeah, I thought so. The only options offered are "Close" and "Go Back." Given that this stuff is all loosely coupled, it really ought to be designed to deal with failure--not just give up.

Has anyone patched MT to work around this problem? I'm sure this problem isn't specific to me.

This will get posted eventually, I hope.

Update: Yup, had to post this a day later.

Posted by jzawodn at June 30, 2003 10:28 AM

Reader Comments
# Tomas said:

That sounds like quite a significant bug, I don't use Google API so it's of little concern to me, but if I were you I'd bring it to Ben Trott's attention. I bet the tip will be very well received.

on June 30, 2003 10:34 AM
# Dave Winer said:

In Radio or Manila you'd get a macro error where the macro failed, but the page would still build/display.

on June 30, 2003 10:51 AM
# Gavin said:

It's a problem with all MT plugins. The plugin dies and the whole process dies.

I work around this by caching all plugin output so that when I rebuild by adding a new post, somebody posts a comment etc, the rebuild happens quickly (and with little chance of timing out). I then rebuild the index page every couple of hours with a cron job.

http://www.movabletype.org/support/index.php?act=ST&f=20&t=18953

on June 30, 2003 11:17 AM
# J$ said:

Wouldn't putting a "or return '';" after the SOAP::Lite call to google work? That is, on line 1749 or so of Context.pm where you findmy $result = SOAP::Lite->service('file:' . $wsdl)->doGoogleSearch($key, $query, 0, $max, 0, '', 0, '', 'latin1', 'latin1');Change that to:my $result = SOAP::Lite->service('file:' . $wsdl)->doGoogleSearch($key, $query, 0, $max, 0, '', 0, '', 'latin1', 'latin1') or return '';I haven't tested it, but I would think that that should work.

on June 30, 2003 12:25 PM
# Ben said:

Hi Jeremy, I just sent you a patch via email to make Google API failures non-fatal. Let me know if you have any problems.

Gavin--actually, errors are fatal in plugins only if the plugins make those errors fatal. If the plugin returns '' (the empty string), there's no error. An undef return value is an error, and the plugin can pass in the error string by returning using the 'error' method.

on June 30, 2003 03:03 PM
# Tomas said:

That's great, Dave. Are you saying that Radio and Manila does not have bugs nor problems? Or are you just trying to pick cheap points? Either way, it's low.

on July 1, 2003 01:29 AM
# J$ said:

Ben:

I never received your email, but just to let anyone else who read my above comment know, that fix that I suggested does not work. It gives an "undefined reference to a subroutine" error. I poked around for about two more minutes before deciding that I should be doing my "real work" instead of MT-playtime.

But, Ben, fire off that patch to me again. My email is "jms18 [at sign] cwru dot edu". Thanks!

J$

on July 1, 2003 11:15 AM
# J$ said:

Okay, I created a work-around for Context.pm. Here is the diff. This is for MT v2.64.diff -C 3 Template/Context.pm Template/Context.pm.old
*** Template/Context.pm Tue Jul 1 14:54:20 2003
--- Template/Context.pm.old Tue Jul 1 14:50:45 2003
***************
*** 1748,1780 ****
\&SOAP::XMLSchema2001::Deserializer::as_boolean;
}

! my $result;
!
! eval {
! $result = SOAP::Lite->service('file:' . $wsdl)
->doGoogleSearch($key, $query, 0, $max,
0, '', 0, '', 'latin1', 'latin1'
);
- };

my $tokens = $ctx->stash('tokens');
my $builder = $ctx->stash('builder');
my $res = '';
!
! if( ($@) || (!(@{ $result->{resultElements} })) )
! {
! $ctx->stash('google_result', '');
my $out = $builder->build($ctx, $tokens, $cond);
! }
! else
! {
! for my $rec (@{ $result->{resultElements} }) {
! $ctx->stash('google_result', $rec);
! my $out = $builder->build($ctx, $tokens, $cond);
! return $ctx->error( $builder->errstr ) unless defined $out;
! $res .= $out;
! }
! }
$res;
}

--- 1748,1767 ----
\&SOAP::XMLSchema2001::Deserializer::as_boolean;
}

! my $result = SOAP::Lite->service('file:' . $wsdl)
->doGoogleSearch($key, $query, 0, $max,
0, '', 0, '', 'latin1', 'latin1'
);

my $tokens = $ctx->stash('tokens');
my $builder = $ctx->stash('builder');
my $res = '';
! for my $rec (@{ $result->{resultElements} }) {
! $ctx->stash('google_result', $rec);
my $out = $builder->build($ctx, $tokens, $cond);
! return $ctx->error( $builder->errstr ) unless defined $out;
! $res .= $out;
! }
$res;
}


At least, that worked for me.

on July 1, 2003 12:09 PM
# Dave Winer said:

Tomas, of course they have bugs, just not this particular one.

on July 2, 2003 12:15 PM
Disclaimer: The opinions expressed here are mine and mine alone. My current, past, or previous employers are not responsible for what I write here, the comments left by others, or the photos I may share. If you have questions, please contact me. Also, I am not a journalist or reporter. Don't "pitch" me.

 

Privacy: I do not share or publish the email addresses or IP addresses of anyone posting a comment here without consent. However, I do reserve the right to remove comments that are spammy, off-topic, or otherwise unsuitable based on my comment policy. In a few cases, I may leave spammy comments but remove any URLs they contain.