Open haines opened 9 months ago
I also encountered a similar issue where I used a database extension to fetch and store Yjs document data from MySQL.
MySQL sometimes throws an error (unable to "insert on duplicate", "upsert"), which will cause the entire Node.js server instance to crash.
I ran into this myself. Note that there's an undocumented escape hatch: https://github.com/ueberdosis/hocuspocus/blob/edd7034aece9ba41dcb4efff1207fd06624f319d/packages/server/src/Hocuspocus.ts#L538-L540
If your error does not have a message
field, it will be 'handled'. Of course, then you're left with an unsaved document and need to solve that somehow.
This is why the redis extension doesn't crash the server when it can't a lock for the document.
I'm not posting to discount the issue, just highlight something you might be able to use in the meantime. I agree there should be some documented way for hooks to fail without crashing. And, for onStoreDocument
in particular, maybe there is some API / options for how to handle when a document fails to save (e.g. automatically scheduling a retry later).
Description Most of the hook invocations are not guarded with
.catch()
ortry
-await
-catch
, so promise rejections are unhandled. This causes a server crash by default.Steps to reproduce the bug Steps to reproduce the behavior:
onStoreDocument
Expected behavior Errors should be handled appropriately.