@@ -33,6 +33,8 @@ class PublishFinalizationCommand extends Command {
3333 const { id, publishOperationId, merkleRoot, byteSize } = eventData ;
3434 const { blockchain, contractAddress } = event ;
3535 const operationId = this . operationIdService . generateId ( ) ;
36+ const ual = this . ualService . deriveUAL ( blockchain , contractAddress , id ) ;
37+
3638 this . operationIdService . emitChangeEvent (
3739 OPERATION_ID_STATUS . PUBLISH_FINALIZATION . PUBLISH_FINALIZATION_START ,
3840 operationId ,
@@ -71,7 +73,9 @@ class PublishFinalizationCommand extends Command {
7173 assertion = result . assertion ;
7274 publisherPeerId = result . remotePeerId ;
7375 } catch ( error ) {
74- this . logger . error ( `Failed to read cached publish data: ${ error . message } ` ) ; // TODO: Make this log more descriptive
76+ this . logger . error (
77+ `[Cache] Failed to read cached publish data for UAL ${ ual } (publishOperationId: ${ publishOperationId } , txHash: ${ txHash } , operationId: ${ operationId } ): ${ error . message } ` ,
78+ ) ;
7579 this . operationIdService . emitChangeEvent (
7680 OPERATION_ID_STATUS . FAILED ,
7781 operationId ,
@@ -81,8 +85,6 @@ class PublishFinalizationCommand extends Command {
8185 return Command . empty ( ) ;
8286 }
8387
84- const ual = this . ualService . deriveUAL ( blockchain , contractAddress , id ) ;
85-
8688 try {
8789 await this . validatePublishData ( merkleRoot , cachedMerkleRoot , byteSize , assertion , ual ) ;
8890 } catch ( e ) {
@@ -185,23 +187,31 @@ class PublishFinalizationCommand extends Command {
185187
186188 async readWithRetries ( publishOperationId ) {
187189 let attempt = 0 ;
190+ const datasetPath = this . fileService . getPendingStorageDocumentPath ( publishOperationId ) ;
188191
189192 while ( attempt < MAX_RETRIES_READ_CACHED_PUBLISH_DATA ) {
190193 try {
191- const datasetPath =
192- this . fileService . getPendingStorageDocumentPath ( publishOperationId ) ;
193194 // eslint-disable-next-line no-await-in-loop
194195 const cachedData = await this . fileService . readFile ( datasetPath , true ) ;
196+ this . logger . debug (
197+ `[Cache] Read cached publish data on attempt ${ attempt + 1 } (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ).` ,
198+ ) ;
195199 return cachedData ;
196200 } catch ( error ) {
197201 attempt += 1 ;
202+ this . logger . warn (
203+ `[Cache] Attempt ${ attempt } to read cached publish data failed (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ): ${ error . message } ` ,
204+ ) ;
198205
199206 // eslint-disable-next-line no-await-in-loop
200207 await new Promise ( ( resolve ) => {
201208 setTimeout ( resolve , RETRY_DELAY_READ_CACHED_PUBLISH_DATA ) ;
202209 } ) ;
203210 }
204211 }
212+ this . logger . error (
213+ `[Cache] Exhausted retries reading cached publish data (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ).` ,
214+ ) ;
205215 // TODO: Mark this operation as failed
206216 throw new Error ( 'Failed to read cached publish data' ) ;
207217 }
0 commit comments