Aam-Digital / ndb-core

Easy-to-use case management web app for NGOs anywhere in the world.
http://www.aam-digital.com
GNU General Public License v3.0
47 stars 14 forks source link

handle "Failed to fetch" errors in SyncService #2433

Closed sentry-io[bot] closed 5 days ago

sentry-io[bot] commented 1 week ago

The PouchDB requests during Sync initialization may fail, which is causing unhandled exceptions. Improve the SyncService for better error handling.

Sentry Issue: AAM-DIGITAL-4P3

TypeError: Failed to fetch
  at SyncService.sendRequest (./src/app/core/database/sync.service.ts:103:20)
  at f$1 (./src/app/core/database/sync.service.ts:81:23)
  at Generator.next (<anonymous>)
  at Generator.next (<anonymous>)
...
(27 additional frame(s) were not displayed)

also, without being logged in, visiting a public form, the app still sends requests to the /_changes feed and ~(on slow connections?)~ may receive 504 gateway errors

GET https://codo-schlaufox.aam-digital.com/db/app/_changes?include_docs=true&feed=longpoll&heartbeat=10000&since=1625-g1AAAACReJzLYWBgYMpgTmHgzcvPy09JdcjLz8gvLskBCeexAEmGBiD1HwiyMpiTgIINuUAx9hRzcyPjVGN0bTgMSmRIqoebwHwTbIKZuamFZZIpuvosANFCK5M&limit=25 504 (Gateway Timeout)

main.797afe4fa452aaba.js:1 SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON