Skip to content

Can't get Offline integration to work #3046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 9 tasks
mrmckeb opened this issue Nov 11, 2020 · 8 comments · Fixed by #6884 or #6983
Closed
5 of 9 tasks

Can't get Offline integration to work #3046

mrmckeb opened this issue Nov 11, 2020 · 8 comments · Fixed by #6884 or #6983
Assignees

Comments

@mrmckeb
Copy link

mrmckeb commented Nov 11, 2020

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

All packages at

"@sentry/browser": "^5.27.3",
"@sentry/integrations": "^5.27.3",
"@sentry/node": "^5.27.3",
"@sentry/tracing": "^5.27.3",
"@sentry/webpack-plugin": "^1.13.0",

Description

When testing Sentry for offline support, we've found that any errors that we capture offline are never sent upon reconnection.

I can see in the Network tab in DevTools that sentry sends the initial data, then when I go offline, cause an error (because the app is offline) and then go online, the error is never sent.

That same error handler can be triggered by blocking the same request in DevTools (when online) and Sentry immediately reports the error.

If I perform these as a series of actions, I can see in the breadcrumbs where the offline error is thrown (there's even a console.error there) but Sentry's breadcrumbs don't show the exception.

I can provide links privately and I'm happy to get on a Meet/Zoom/etc call to pair on this and demonstrate the issue.

@mrmckeb
Copy link
Author

mrmckeb commented Nov 11, 2020

It seems like there's an error being thrown in localForage:
image

@rodolfoBee
Copy link
Member

Thank you for the feedback, the Offline integration is still a WIP.

@piohhmy
Copy link

piohhmy commented Feb 8, 2021

Hi there 👋 . Any update on official support/docs for Offline integration?

@lukegardiner
Copy link

Please support this. Very simple to build a queue and persist it into some browser storage...

@fritz-c
Copy link

fritz-c commented Oct 21, 2022

I'm not sure if this ticket was facing the same problem, but I discovered there's an inherent conflict with the included-by-default Dedupe integration that will cause single errors cached while offline to disappear once back online. I found this by turning on debug in the init options and observing where the events were disappearing.

My understanding of the issue:
An event is created while offline. Dedupe sees it and marks it as the last seen event. The event makes its way through the other integrations until it reaches the Offline integration. Since the network is offline, Offline will cache the event until later. When the app is back online, Offline will re-capture the event, sending it back through the integrations again. Once it reaches Dedupe again, Dedupe sees the event as identical to the one that just went through it the last time around, and drops it, never to be sent by Sentry.

One caveat that made debugging a real hassle: if more than one event is captured while online, either none of the events or one of the events may disappear, as the localforage library used in Offline provides no guarantee of order preservation, so if the last event seen while offline is the first event up to be iterated through in Offline, it may get filtered out by Dedupe.

Anyway, putting Dedupe somewhere after Offline will fix it. This did it for me:

Sentry.init({
  ...sharedConfig,

  integrations: (integrations) => {
    const integrationsMinusDedupe = integrations.concat();
    const dedupeIndex = integrations.findIndex((i) => i.name === "Dedupe");
    const dedupeInAnArray =
      dedupeIndex >= 0 ? integrationsMinusDedupe.splice(dedupeIndex, 1) : [];

    return [
      ...integrationsMinusDedupe,
      new OfflineIntegration({ maxStoredEvents: 30 }),
      ...dedupeInAnArray,
    ];
  },
});

@timfish
Copy link
Collaborator

timfish commented Nov 29, 2022

I think we should replace the Offline Integration with a transport wrapper that adds offline caching to any existing transport. This is roughly how the offline transport works for Electron.

@AbhiPrasad
Copy link
Member

Re-opening because only closed by #6983

@AbhiPrasad
Copy link
Member

Docs: getsentry/sentry-docs#6292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants