No, Larch doesn't have any built-in inactivity timeouts, and even if
the server drops the connection for some reason, Larch should
reconnect automatically.
However, there is a nasty deadlock bug in Ruby's Net::IMAP library
that can cause it to hang indefinitely (without sending an exception
to Larch) if the connection is dropped during certain stages of
certain actions, and message transfer is the most common case where
this occurs. There's a warning about this in the Known Issues section
of the Larch readme.
Unfortunately there's nothing I can do about this Net::IMAP bug. Well,
nothing safe, anyway...I could monkeypatch it, but then I'd have to
have some way of ensuring that users only run Larch on a single
specific Ruby version.
- Ryan
It's been a few months since I looked into this so my memory's a bit
rusty, but I believe you'd need to modify Net::IMAP's
get_tagged_response and get_response methods to be more robust about
handling different kinds of socket errors. There may also be cases
elsewhere in Net::IMAP where the library can get stuck endlessly
waiting for the next character of a malformed response, although I
haven't confirmed this yet.
The problem with monkeypatching a standard lib is that it differs
between Ruby versions, so you'd have to have a patch compatible with
every supported version, which would be a nightmare.
> I'm running into what I think is this problem quite a bit with the
> migration I'm trying to do, and in a reproducible way (always on
> particular messages so I can't just CTRL-C and try again). I'm not
> sure what I'd be looking for, but I can't find a common thread in the
> messages that hang it up, though there seem to be several, and unless
> I exclude the containing folder, larch hangs up consistently. The last
> [debug] message is "peeking at message" and:
>
> @pos: 3254
> @lex_state: EXPR_DATA
> @token.symbol: LPAR
> @token.value: "("
>
> is an example of the sort of thing I'd see in the last few lines of
> output in "insane" mode.
Hmm. That's interesting. This may be a case where either the message
or the server response is somehow malformed and is causing Net::IMAP
to sit waiting for a token that never arrives.
One way to narrow this down a bit: manually copy one or more of the
problem messages to another server running different IMAP software,
then run Larch against both. If one server works fine and the other
doesn't, then it's likely to be a malformed server response that's the
issue. If both servers fail on the same message, then the message
itself is triggering the issue.
- Ryan
Thanks for following up with the results. I'll make a note of this in
the Larch documentation in case other users run into similar problems.
- Ryan