diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 39a22f6c716d..37e1ef49689a 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -20130,9 +20130,13 @@ FactoryOp::ActorDestroy(ActorDestroyReason aWhy) NoteActorDestroyed(); - if (mState == State::WaitingForTransactionsToComplete || - (mState == State::SendingResults && aWhy != Deletion)) { - // We didn't get an opportunity to clean up. Do that now. + // There may be an event in the event queue that would do the cleanup later, + // but if we are being destroyed abnormally (not by calling + // PBackgroundIDBFactoryRequestParent::Send__delete__) we need to do the + // cleanup here and just ignore the cleanup event in FactoryOp::Run. + // Otherwise some Database objects may be still alive and registered in + // gLiveDatabaseHashtable at the time the last factory is destroyed. + if (aWhy != Deletion) { mState = State::SendingResults; IDB_REPORT_INTERNAL_ERR(); mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;