network.js
network.js copied to clipboard
Add XHR error handling for offline
My use case is if the browser becomes offline and the XHR requests begin to error, my JS app continues to run and watch for online availability.
This adds a hook to push null into the latency array if the XHR request responded with the error event, allowing the net.latency.on( 'end' ) callback to receive null information and conclude there is no connection. Not sure if these needs to accommodate for intentional server errors, but it's an improvement in my case.