Skip to content

Commit

Permalink
fix(realtime): Resilience to errors in subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
edas committed Feb 26, 2020
1 parent 9974e9d commit 30f5d33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/cozy-realtime/src/CozyRealtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,13 @@ class CozyRealtime {
logger.info('receive message from server', { event, payload })
const handlers = this.subscriptions.getAllHandlersForEvent(event, payload)
for (const handler of handlers) {
handler(payload.doc)
try {
handler(payload.doc)
} catch (e) {
logger.error(
`handler did throw for ${event}, ${payload.type}, ${payload.id}`
)
}
}
if (event === 'error') {
logger.warn('Stack returned an error', payload)
Expand Down

0 comments on commit 30f5d33

Please sign in to comment.