Search code examples
ember.jsember-datamobile-safari

Ember Data 0 Payload Empty Content-Type


It seems to be somewhat sporadic, and I myself have not been able to replicate the issue using similar hardware, but on Mobile Safari, I am occaisionally seeing errors in Raygun (error tracking software) similar to:

Ember Data Request GET api/v1/sales/recent returned a 0 Payload (Empty Content-Type)

Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_4 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G35 Safari/601.1

Trouble is, investigating the logs, I see no requests to that API failing at those times, (200 or 304 statuses) so I'm wondering what could possibly be happening and whether this is an Ember Data issue or if perhaps my API is responding with something ED doesn't like.

DEBUG: -------------------------------
DEBUG: Ember      : 2.4.5
DEBUG: Ember Data : 2.4.3
DEBUG: jQuery     : 2.2.4
DEBUG: -------------------------------

Solution

  • This error was a thorn in my side for months. I looked at how Ember Data was building its error message and realized that the 0 in the error message is supposed to be the status code. Some colleagues pointed out to me that status code 0 generally occurs when an XHR is cancelled by the browser. So I turned on Network Throttling in Chrome Dev Tools and hit refresh during an XHR and was able to reproduce the error reliably. So it is just a client cancelling a request and can be ignored.