@@ -598,29 +598,49 @@ class SnapProcessor extends BaseProcessor {
598598 useMessageRecording = 1 ;
599599 }
600600
601- insertButton . run (
602- buttonIdCounter ++ ,
603- button . label || '' ,
604- button . message || button . label || '' ,
605- navigatePageId ,
606- elementRefId ,
607- null ,
608- null ,
609- messageRecordingId ,
610- serializedMetadata ,
611- useMessageRecording ,
612- button . style ?. fontColor ? parseInt ( button . style . fontColor . replace ( '#' , '' ) , 16 ) : null ,
613- button . style ?. backgroundColor
614- ? parseInt ( button . style . backgroundColor . replace ( '#' , '' ) , 16 )
615- : null ,
616- button . style ?. borderColor
617- ? parseInt ( button . style . borderColor . replace ( '#' , '' ) , 16 )
618- : null ,
619- button . style ?. borderWidth ,
620- button . style ?. fontSize ,
621- button . style ?. fontFamily ,
622- button . style ?. fontStyle ? parseInt ( button . style . fontStyle ) : null
623- ) ;
601+ // Retry logic for SQLite operations
602+ let retries = 3 ;
603+ while ( retries > 0 ) {
604+ try {
605+ insertButton . run (
606+ buttonIdCounter ++ ,
607+ button . label || '' ,
608+ button . message || button . label || '' ,
609+ navigatePageId ,
610+ elementRefId ,
611+ null ,
612+ null ,
613+ messageRecordingId ,
614+ serializedMetadata ,
615+ useMessageRecording ,
616+ button . style ?. fontColor
617+ ? parseInt ( button . style . fontColor . replace ( '#' , '' ) , 16 )
618+ : null ,
619+ button . style ?. backgroundColor
620+ ? parseInt ( button . style . backgroundColor . replace ( '#' , '' ) , 16 )
621+ : null ,
622+ button . style ?. borderColor
623+ ? parseInt ( button . style . borderColor . replace ( '#' , '' ) , 16 )
624+ : null ,
625+ button . style ?. borderWidth ,
626+ button . style ?. fontSize ,
627+ button . style ?. fontFamily ,
628+ button . style ?. fontStyle ? parseInt ( button . style . fontStyle ) : null
629+ ) ;
630+ break ; // Success
631+ } catch ( err : any ) {
632+ if ( err . code === 'SQLITE_IOERR' && retries > 1 ) {
633+ retries -- ;
634+ // Wait a bit before retrying
635+ const now = Date . now ( ) ;
636+ while ( Date . now ( ) - now < 100 ) {
637+ /* busy wait */
638+ }
639+ } else {
640+ throw err ;
641+ }
642+ }
643+ }
624644
625645 // Insert ElementPlacement
626646 const insertPlacement = db . prepare (
0 commit comments