Skip to content

unawaited patch never executes #26

Open
@ldanilek

Description

@ldanilek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs feedbackLooking for justification via real world use cases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions