Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most hook promise rejections are unhandled #754

Open
haines opened this issue Dec 6, 2023 · 2 comments
Open

Most hook promise rejections are unhandled #754

haines opened this issue Dec 6, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@haines
Copy link
Contributor

haines commented Dec 6, 2023

Description
Most of the hook invocations are not guarded with .catch() or try-await-catch, so promise rejections are unhandled. This causes a server crash by default.

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. Return a rejected promise from a hook e.g. onStoreDocument
  2. Server process crashes due to unhandled rejection

Expected behavior
Errors should be handled appropriately.

@haines haines added the bug Something isn't working label Dec 6, 2023
@shincurry
Copy link
Contributor

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.

@timreinkeaxios
Copy link

I ran into this myself. Note that there's an undocumented escape hatch:

if (error?.message) {
throw error
}

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants