File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed 
packages/gatsby/src/datastore/lmdb Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -202,10 +202,11 @@ function updateDataStore(action: ActionsUnion): void {
202202    case  `ADD_CHILD_NODE_TO_PARENT_NODE` :
203203    case  `MATERIALIZE_PAGE_MODE` : { 
204204      const  dbs  =  getDatabases ( ) 
205-       lastOperationPromise  =  Promise . all ( [ 
205+       const   operationPromise  =  Promise . all ( [ 
206206        updateNodes ( dbs . nodes ,  action ) , 
207207        updateNodesByType ( dbs . nodesByType ,  action ) , 
208208      ] ) 
209+       lastOperationPromise  =  operationPromise 
209210
210211      // if create is used in the same transaction as delete we should remove it from cache 
211212      if  ( action . type  ===  `CREATE_NODE` )  { 
@@ -216,8 +217,11 @@ function updateDataStore(action: ActionsUnion): void {
216217        preSyncDeletedNodeIdsCache . add ( 
217218          ( ( action  as  IDeleteNodeAction ) . payload  as  IGatsbyNode ) . id 
218219        ) 
219-         lastOperationPromise . then ( ( )  =>  { 
220-           preSyncDeletedNodeIdsCache . clear ( ) 
220+         operationPromise . then ( ( )  =>  { 
221+           // only clear if no other operations have been done in the meantime 
222+           if  ( lastOperationPromise  ===  operationPromise )  { 
223+             preSyncDeletedNodeIdsCache . clear ( ) 
224+           } 
221225        } ) 
222226      } 
223227    } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments