@@ -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,36 @@ 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 ) ;
194+ const stats = await this . fileService . stat ( datasetPath ) ;
195+ this . logger . debug (
196+ `[Cache] Cache file present on attempt ${ attempt + 1 } (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } , size: ${ stats . size } bytes).` ,
197+ ) ;
198+
193199 // eslint-disable-next-line no-await-in-loop
194200 const cachedData = await this . fileService . readFile ( datasetPath , true ) ;
201+ this . logger . debug (
202+ `[Cache] Read cached publish data on attempt ${ attempt + 1 } (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ).` ,
203+ ) ;
195204 return cachedData ;
196205 } catch ( error ) {
197206 attempt += 1 ;
207+ this . logger . warn (
208+ `[Cache] Attempt ${ attempt } to read cached publish data failed (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ): ${ error . message } ` ,
209+ ) ;
198210
199211 // eslint-disable-next-line no-await-in-loop
200212 await new Promise ( ( resolve ) => {
201213 setTimeout ( resolve , RETRY_DELAY_READ_CACHED_PUBLISH_DATA ) ;
202214 } ) ;
203215 }
204216 }
217+ this . logger . error (
218+ `[Cache] Exhausted retries reading cached publish data (publishOperationId: ${ publishOperationId } , path: ${ datasetPath } ).` ,
219+ ) ;
205220 // TODO: Mark this operation as failed
206221 throw new Error ( 'Failed to read cached publish data' ) ;
207222 }
0 commit comments