woocommerce-ios icon indicating copy to clipboard operation
woocommerce-ios copied to clipboard

NSManagedObjectContext.saveIfNeeded Crash

Open sentry-io[bot] opened this issue 4 years ago • 11 comments

Sentry Issue: WOOCOMMERCE-IOS-1CEN

EXC_BREAKPOINT: Fatal error > Storage/NSManagedObjectContext+Storage.swift
  File "NSManagedObjectContext+Storage.swift", line 140, in NSManagedObjectContext.saveIfNeeded
  File "<compiler-generated>", in NSManagedObjectContext
  File "CoreDataManager.swift", line 148, in CoreDataManager.saveDerivedType
  File "<compiler-generated>", in CoreDataManager.saveDerivedType
  File "<compiler-generated>", in @callee_guaranteed
...
(11 additional frame(s) were not displayed)

Created by @shiki


This is caused by disk space issues (https://github.com/woocommerce/woocommerce-ios/issues/3246). But this just goes to show that we should really not crash the app if saveIfNeeded fails.

sentry-io[bot] avatar Nov 30 '20 17:11 sentry-io[bot]

Sentry issue: WOOCOMMERCE-IOS-1CFA

sentry-io[bot] avatar Nov 30 '20 17:11 sentry-io[bot]

11 events, 9 users as of 16/12/2020

Ecarrion avatar Dec 16 '20 21:12 Ecarrion

As of Feb 4, 2021: 21 events, 18 users.

shiki avatar Feb 04 '21 23:02 shiki

As of Feb 22, 2021: 33 events, 23 users.

shiki avatar Feb 22 '21 19:02 shiki

Sentry issue: WOOCOMMERCE-IOS-1CY4

sentry-io[bot] avatar Mar 22 '22 21:03 sentry-io[bot]

Sentry issue: WOOCOMMERCE-IOS-1DD1

sentry-io[bot] avatar May 16 '22 13:05 sentry-io[bot]

Prioritization: Severity – high: crash Impact – low: 30/131k users (30 days) = medium

joshheald avatar May 19 '22 11:05 joshheald

Sentry issue: WOOCOMMERCE-IOS-1DF5

sentry-io[bot] avatar Aug 04 '22 23:08 sentry-io[bot]

Sentry issue: WOOCOMMERCE-IOS-1DF5

I'm not sure if is related, but this last one comes with logs attached at the same time of the crash pointing to a Networking error and to a deprecated endpoint for shipping:

2022/08/08 13:02:39:383  ⚠️ You are using an older version of the Woo REST API: wc/v2, for path: orders/10206/shipment-trackings/
2022/08/08 13:02:40:400  🔵 Tracked order_notes_loaded
2022/08/08 13:02:41:178  ⛔️ Error synchronizing tracking: L’opération n’a pas pu s’achever. (Networking.DotcomError erreur 5.)
2022/08/08 13:02:41:202  Order 10206 not eligible for shipping label creation: store_not_eligible

While we log this error via DDLog on checkCreationEligibility() and we do not crash the app at this point, I wonder if could be related to attempting to do a CRUD operation before we get the callback from the ShippingLabelRemote: We call .saveIfNeeded() 4 times in ShipmentStore involving storage and a shipping label and try to save this data if has changed:

  • upsertTrackingProviderData
  • deleteStoredShipment
  • addStoredShipment
  • addCustomStoredShipment

The NSManagedObjectContext+Storage:

    /// Persists the changes (if any) to disk.
    ///
    public func saveIfNeeded() {
        guard hasChanges else {
            return
        }

        do {
            try save()
        } catch {
            let nserror = error as NSError
            logErrorAndExit("Unresolved error \(nserror), \(nserror.userInfo)")
        }
    }

iamgabrielma avatar Aug 08 '22 14:08 iamgabrielma

Sentry issue: WOOCOMMERCE-IOS-1DH1

sentry-io[bot] avatar Aug 08 '22 14:08 sentry-io[bot]

Sentry issue: WOOCOMMERCE-IOS-1DHD

sentry-io[bot] avatar Aug 18 '22 06:08 sentry-io[bot]