Loading
fix(sync): handle nil progress values in session processing and batch uploads
Fixed critical bug where nil start_progress and end_progress values caused arithmetic errors (nil - nil) during session processing and batch payload construction. This was causing silent batch failures where only a small fraction of sessions were actually synced (e.g., 11/1300 sessions). Changes: 1. Session calculation (_calculateSessionsFromPageStats): - Line 1968: Fixed nil arithmetic when saving sessions at gap boundaries - Line 2009: Fixed nil arithmetic when saving final session - Now properly defaults to 0 before calculating progress_delta 2. Batch upload payload construction (_uploadSessionsWithBatching): - Line 2371-2373: Extract and default progress values before arithmetic - Prevents nil - nil errors in batch payloads - Ensures all three progress fields use consistent defaulted values 3. Enhanced logging for batch operations: - Added detailed logging before/after each batch attempt - Logs success status, HTTP codes, and error messages - Improved error messages with batch number, session count, and codes - Makes debugging batch failures much easier All locations now follow the same pattern: - Extract start_progress with default 0 - Extract end_progress with default 0 - Calculate progress_delta using defaulted values - Apply rounding/formatting to all three values Note: _submitSingleSession() already had this fix in place.