@@ -441,20 +441,20 @@ class StorageImpl implements Storage {
441441 source : doc . sourceCell ?. entityId ,
442442 } ;
443443
444- // 🤔 I'm guessing we should be storting schema here
444+ // 🤔 I'm guessing we should be storing schema here
445445
446446 if ( JSON . stringify ( value ) !== JSON . stringify ( this . writeValues . get ( doc ) ) ) {
447- this . writeDependentDocs . set ( doc , dependencies ) ;
448- this . writeValues . set ( doc , value ) ;
449-
450- this . _addToBatch ( [ { doc, type : "storage" } ] ) ;
451-
452447 log ( ( ) => [
453448 "prep for storage" ,
454449 JSON . stringify ( doc . entityId ) ,
455450 value ,
451+ this . writeValues . get ( doc ) ,
456452 [ ...dependencies ] . map ( ( c ) => JSON . stringify ( c . entityId ) ) ,
457453 ] ) ;
454+ this . writeDependentDocs . set ( doc , dependencies ) ;
455+ this . writeValues . set ( doc , value ) ;
456+
457+ this . _addToBatch ( [ { doc, type : "storage" } ] ) ;
458458 }
459459 }
460460
@@ -788,12 +788,13 @@ class StorageImpl implements Storage {
788788 return storage . send ( jobs ) . then ( ( result ) => retryOnConflict ( result ) )
789789 . then ( ( result ) => {
790790 if ( result . ok ) {
791+ log ( ( ) => [ "storage ok" , JSON . stringify ( result . ok , null , 2 ) ] ) ;
791792 // Apply updates from retry, if transaction ultimately succeeded
792793 updatesFromRetry . forEach ( ( [ doc , value ] ) =>
793794 this . _batchForDoc ( doc , value . value , value . source )
794795 ) ;
795796 } else if ( result . error ) {
796- log ( ( ) => [ "storage error" , result . error ] ) ;
797+ log ( ( ) => [ "storage error" , JSON . stringify ( result . error , null , 2 ) ] ) ;
797798 console . error ( "storage error" , result . error ) ;
798799 }
799800 return result ;
@@ -803,7 +804,7 @@ class StorageImpl implements Storage {
803804 // Write all storage jobs to storage, in parallel
804805 const promiseJobs = [ ] ;
805806 for ( const [ space , jobs ] of storageJobsBySpace . entries ( ) ) {
806- promiseJobs . push ( process ( space , jobs ) ) ;
807+ if ( jobs . length ) promiseJobs . push ( process ( space , jobs ) ) ;
807808 }
808809 await Promise . all ( promiseJobs ) ;
809810 log ( ( ) => [ "storage jobs done" ] ) ;
0 commit comments