bugsnag / bugsnag-cocoa

BugSnag error monitoring & exception reporter for iOS, macOS, tvOS and watchOS
https://docs.bugsnag.com/platforms/ios
MIT License
234 stars 128 forks source link

Synchronously send errors/exceptions via `notifyError:` or `notify:` #1674

Closed sapharow closed 1 month ago

sapharow commented 2 months ago

Description

Sometimes it is required to ensure that the crash was uploaded before proceeding further.

Describe the solution you'd like

I would like to have extra methods with upload completion blocks in the Bugsnag interface to facilitate this. For example:

+ (void)notify:(NSException *_Nonnull)exception 
    completion:(void(^)())completion;

+ (void)notify:(NSException *_Nonnull)exception 
         block:(BugsnagOnErrorBlock _Nullable)block 
    completion:(void(^)())completion;

+ (void)notifyError:(NSError *_Nonnull)error 
         completion:(void(^)())completion;

+ (void)notifyError:(NSError *_Nonnull)error 
              block:(BugsnagOnErrorBlock _Nullable)block 
         completion:(void(^)())completion;

Describe alternatives you've considered

There is no way to ensure that the log was uploaded, so we have forked BugSnag passing the completion callback all the way down to the eventUploader:completionHandler: to achieve this.

mclack commented 2 months ago

Hi @sapharow

We would generally recommend against halting code execution until a network request resolves, as this has the potential to have a negative impact on the end user experience, especially in situations where there is a bad network connection or none at all. It's also worth noting that a 200 response from our error reporting API simply indicates that the event payload has been accepted, and the pipeline could still potentially discard an event afterwards for multiple reasons.

Alongside the above, our reporting is intended to be statistical, and we do not expect every crash to be successfully captured. BugSnag will, however, provide a valuable insight into the overall cause of errors by displaying a percentage of errors experienced by your users.

For our further understanding, would you be able to provide some additional information around what scenarios you'd want to ensure that a crash is reported before proceeding? Would implementing this effectively freeze the UI? And would you intend to have a limit to this? Say, for example, "stop the execution of code until the crash is reported, unless it takes longer than x seconds"?

As this is a public thread, please feel free to share any additional information with us directly by contacting us at support@bugsnag.com.

sapharow commented 1 month ago

Replied to the email provided and taking further discussion to support ticket.

clr182 commented 1 month ago

Hi @sapharow

As the conversation has moved to a support ticket I am going to close this issue out. You should expect any further updates to come in the form of a response from the Support ticket you opened.