woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
310 stars 111 forks source link

NSManagedObjectContext.saveIfNeeded Crash #3247

Open sentry-io[bot] opened 3 years ago

sentry-io[bot] commented 3 years ago

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] commented 3 years ago

Sentry issue: WOOCOMMERCE-IOS-1CFA

Ecarrion commented 3 years ago

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

shiki commented 3 years ago

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

shiki commented 3 years ago

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

sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-IOS-1CY4

sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-IOS-1DD1

joshheald commented 2 years ago

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

sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-IOS-1DF5

iamgabrielma commented 2 years ago

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:

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)")
        }
    }
sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-IOS-1DH1

sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-IOS-1DHD