Skip to content

Commit aa1119e

Browse files
committed
catch errors thrown by event handlers
1 parent 7bf50dd commit aa1119e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sync.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ export const readSyncStep1 = (decoder, encoder, doc) =>
7979
* @param {any} transactionOrigin
8080
*/
8181
export const readSyncStep2 = (decoder, doc, transactionOrigin) => {
82-
Y.applyUpdate(doc, decoding.readVarUint8Array(decoder), transactionOrigin)
82+
try {
83+
Y.applyUpdate(doc, decoding.readVarUint8Array(decoder), transactionOrigin)
84+
} catch (error) {
85+
// This catches errors that are thrown by event handlers
86+
console.error('Caught error while handling a Yjs update', error)
87+
}
8388
}
8489

8590
/**

0 commit comments

Comments
 (0)