nesk / network.js

Make accurate network measures (like Speedtest) in your browser
MIT License
297 stars 89 forks source link

Add XHR error handling for offline #60

Open bradgreens opened 8 years ago

bradgreens commented 8 years ago

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.