bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

Offline support?

Open machty opened this issue 10 years ago • 18 comments

It seems there's no support for enqueuing notifications for later when the app is offline. Is there any plan to add this in the future?

machty avatar Sep 04 '15 04:09 machty

How exactly would that work? And how would that relate to JavaScript errors?

jmshal avatar Sep 04 '15 08:09 jmshal

Client-side analytics platforms (one example being Localytics) often have error handling on their uploads, such that if the upload fails, it's saved for a later upload in localStorage (but perhaps just storing in memory is all we need). Then at some point in the future, it tries to send a batch of all prior unsent payloads. Bugsnag could adopt a similar approach.

It seems like an important feature just because, without it, you're losing data on any exceptions thrown if the user has a flaky connection at the time of the exception (mobile apps are particularly prone to this).

machty avatar Sep 04 '15 11:09 machty

I see what you mean. To be honest I'd find it unlikely to be implemented into the library itself, but I like the idea. It would seem that it's something that can be implemented on a per-app basis, based on your own specifications. Having such a system would add additional 'bloat' to the existing js file, for something that would probably be an opt-in feature anyway.

Just my opinion, sorry. But I'd never thought about it before now. Very smart.

jmshal avatar Sep 04 '15 11:09 jmshal

For me, this is actually very important. Do any other Bugtracking Services support this for JavaScript-based Errors?

codepunkt avatar Nov 17 '15 07:11 codepunkt

This will also enable an easier integration with Cordova/Ionic applications

abrbhat avatar Apr 05 '16 06:04 abrbhat

Notable: https://developers.google.com/web/updates/2015/12/background-sync

foxyblocks avatar Apr 06 '16 21:04 foxyblocks

So I've put together some code for supporting in-memory error event retrying. There are a few of things to note, which need some feedback (cc @wordofchristian @kattrali).

  • Right now, the notify.bugsnag.com/js endpoint responds with an empty response. Meaning the onerror event on the Image object (when using the default notifyHandler) is fired instead of the onload event (because a zero byte image isn't valid).
    • This would need to be changed so we can retry requests for users with flakey connections, where they do have "online capability", but no actual connectivity.
    • XHR doesn't have this issue, as you can extract the response status from the XHR object, and determine whether the request was successful or not.
  • I still have yet to implement support for IE8, which does have online/offline events & support, but triggers events off the document.body rather than window.
  • There is currently no limit on how many events can be queued in-memory. Do you reckon it's worth adding one? If so, how large/should it be configurable?

jmshal avatar Jul 10 '16 04:07 jmshal

So, just an update, my PR now includes support for using sessionStorage/localStorage for storing the errors to be sent at a later time. I still need to do some more testing (for bugs and browser support), but I'd love to get some feedback on this 😄

cc @kattrali

jmshal avatar Jul 23 '16 01:07 jmshal

There's actually a huge bug I found this week that renders our servers useless if it accidentally goes offline. This would definitely solve that.

https://github.com/bugsnag/bugsnag-js/issues/628

ghost avatar Oct 10 '19 13:10 ghost

Can we please find a way to store reports / breadcrumb and send them when the user gets online again?

mathiasrw avatar Jan 31 '20 01:01 mathiasrw

Hi @mathiasrw - yes this is something that we are looking into and hope to implement in a future release :)

abigailbramble avatar Feb 05 '20 12:02 abigailbramble

Did this get released? Would need this as well!

wojtiku avatar Mar 12 '21 12:03 wojtiku

Hey @wojtiku, this isn't something that's released yet. We'll keep you posted in this thread with any updates, but at the moment I don't have an ETA for this.

xljones avatar Mar 12 '21 14:03 xljones

Hey, is there any update on this? Thanks.

cqcmdwym avatar Oct 14 '21 02:10 cqcmdwym

Hi @cqcmdwym - this is still something on our backlog, and I don't have a firm ETA at the moment. As Xander said above we'll notify this thread as soon as there's any update.

luke-belton avatar Oct 14 '21 08:10 luke-belton

@luke-belton great, looking forward to it.

cqcmdwym avatar Oct 20 '21 07:10 cqcmdwym