Closed Bug 896151 Opened 11 years ago Closed 11 years ago

[email/IMAP][test] intermittent-failure on test_imap_parallelfetch.js

Categories

(Firefox OS Graveyard :: Gaia::E-Mail, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: asuth, Unassigned)

Details

test_imap_parallelfetch.js will sometimes fail because of a race stemming from this code:

      header.onchange = function() {
        // intentionally omitting options... body should be downloaded here.
        header.getBody(function(body) {
...
    folderView.slice.maybeRequestBodies(0, messageCount + 1);


This occurs on messages that contain multiple body parts.  The problem is that onchange is fired as a result of the snippet being generated for the message after the first body-part is downloaded and is independent of fetches for all of the body parts being downloaded.

I think the comment was just being overly optimistic and the right thing is probably to just have the test add an 'onchange' listener on body parts that are not yet fetched and emit the log results only when all parts are downloaded.  I think this still meets the spirit of the test.

needinfoing :lightsofapollo for thoughts in case I missed intended semantics and we should be fixing the implementation proper instead.
Flags: needinfo?(jlal)
I just added a variant to getBody so we can have it not return until the body reps are fully downloaded, since we can already do that.  So now I think we should just use that.  (Doing this as part of getting test_compose working for fake activesync.  Quite a slog.)

doc-block for getBody will soon be:
  /**
   * Request the `MailBody` instance for this message, passing it to the
   * provided callback function once retrieved.
   *
   * @args[
   *   @param[options @dict[
   *     @key[downloadBodyReps #:default false]{
   *       Asynchronously initiate download of the body reps.  The body may
   *       be returned before the body parts are downloaded, but they will
   *       eventually show up.  Use the 'onchange' event to hear as the body
   *       parts get added.
   *     }
   *     @key[withBodyReps #:default false]{
   *       Don't return until the body parts are fully downloaded.
   *     }
   *   ]]
   * ]
   */
okay, I'm just fixing this using withBodyReps, since it's straightforward.  Speak up if you take issue!
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(jlal)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.