Skip to content

Commit

Permalink
catch errors thrown by event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Feb 9, 2021
1 parent 7bf50dd commit aa1119e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export const readSyncStep1 = (decoder, encoder, doc) =>
* @param {any} transactionOrigin
*/
export const readSyncStep2 = (decoder, doc, transactionOrigin) => {
Y.applyUpdate(doc, decoding.readVarUint8Array(decoder), transactionOrigin)
try {
Y.applyUpdate(doc, decoding.readVarUint8Array(decoder), transactionOrigin)
} catch (error) {
// This catches errors that are thrown by event handlers
console.error('Caught error while handling a Yjs update', error)
}
}

/**
Expand Down

0 comments on commit aa1119e

Please sign in to comment.