Bug 1397593 - Assertion failure: !mOnStartRequestCalled (We should not call OnStartRequest twice) in HttpBaseChannel::DoNotifyListener(), r=valentin
authorMichal Novotny <michal.novotny@gmail.com>
Wed, 13 Sep 2017 12:19:09 +0200
changeset 430157 1c24153baded037d2a375868fed34a872f73e1bf
parent 430156 b0574c079e2cd67f7104e7fd7f5284b0aacfb03d
child 430158 ff90282974cef1e1b73b826f165aa7be26246a6a
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1397593
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1397593 - Assertion failure: !mOnStartRequestCalled (We should not call OnStartRequest twice) in HttpBaseChannel::DoNotifyListener(), r=valentin
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -4432,17 +4432,26 @@ nsHttpChannel::OnCacheEntryAvailable(nsI
     if (!mIsPending) {
         mCacheInputStream.CloseAndRelease();
         return NS_OK;
     }
 
     rv = OnCacheEntryAvailableInternal(entry, aNew, aAppCache, status);
     if (NS_FAILED(rv)) {
         CloseCacheEntry(false);
-        Unused << AsyncAbort(rv);
+        if (mRaceCacheWithNetwork && mNetworkTriggered &&
+            mFirstResponseSource != RESPONSE_FROM_CACHE) {
+            // Ignore the error if we're racing cache with network and the cache
+            // didn't win, The network part will handle cancelation or any other
+            // error. Otherwise we could end up calling the listener twice, see
+            // bug 1397593.
+            LOG(("  not calling AsyncAbort() because we're racing cache with network"));
+        } else {
+            Unused << AsyncAbort(rv);
+        }
     }
 
     return NS_OK;
 }
 
 nsresult
 nsHttpChannel::OnCacheEntryAvailableInternal(nsICacheEntry *entry,
                                              bool aNew,