Q/A: The Curious Case of Error -999
Q: When I debug my application or run the Instant sample application from Xcode, I see log messages like the following show up in the debugger console. What do they mean and how can I get rid of them?
2017-12-20 17:33:26.708636+0100 Instant[32801:407445] Task <E9222022-EA65-4105-8AD1-863F9ACB2C64>.<7> finished with error - code: -999
A: The good news is that this message is nothing to worry about.
-999 is the error code for
NSURLErrorCancelled, which is issued whenever we cancel an HTTP request.
The bad news is that we cannot get rid of this message.
The message comes from within Apple’s
CFNetwork framework, which logs when a running
NSURLSessionTask is canceled, and there is currently no way to silence it.
Q: Why/when do you cancel requests anyway?
A: There are three scenarios in which we cancel requests:
- For real-time updates, we use a technique called HTTP long polling.
This means that if you use
PSPDFInstantViewControllerin its default configuration, the Instant client will make a long-running request to the server in order to listen for remote changes. So whenever we need to push local changes to the server, this long-running request needs to be canceled — and that’s when you will see this in the console.
- In order to preserve energy, we cancel any request that isn’t pushing changes to the server when the app is sent to the background. Requests that push changes are generally allowed to complete.
- We cancel any ongoing request for a
PSPDFDocumentDescriptorwhose local storage is removed, or which is invalidated in any other way. This happens as soon as possible and regardless of the request’s type (push/pull/long poll).
Q: Is there anything I can do about it?
A: Apart from filing a bug report with Apple, unfortunately there is nothing you can do.