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

unawaited patch never executes #26

Open
ldanilek opened this issue Jun 3, 2024 · 0 comments
Open

unawaited patch never executes #26

ldanilek opened this issue Jun 3, 2024 · 0 comments
Labels
needs feedback Looking for justification via real world use cases

Comments

@ldanilek
Copy link

ldanilek commented Jun 3, 2024

promises in convex mutations usually run to completion, even if not awaited.

for example,

handler: async (ctx, { id }) => {
  ctx.db.patch(id, { foo: bar });
}

will execute the patch, even though patch is async and we're not awaiting it. But this isn't true in Ents, because Ents use lazy promises. So a forgotten await can turn into a silent bug. i.e. this code, which looks identical to the above, actually is a no-op:

handler: async (ctx, { id }) => {
  ctx.table("messages").getX(id).patch({ foo: bar });
}

If we could make mutating promises like patch and insert non-lazy, that would help avoid potential bugs.

in the meantime, enabling the linter @typescript-eslint/no-floating-promises https://typescript-eslint.io/rules/no-floating-promises/ makes forgotten-await bug more likely to be found.

@xixixao xixixao added the needs feedback Looking for justification via real world use cases label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs feedback Looking for justification via real world use cases
Projects
None yet
Development

No branches or pull requests

2 participants