David AlonsoD
Convex Community15mo ago
53 replies
David Alonso

Mutation error: `Returned promise will never resolve` caused by triggers

I've never seen this error before, and when i get rid of this trigger in my blocks mutation it goes away...

The original mutation contains some promise all statements that insert docs into the blocks table

Any ideas?
triggers.register("blocks", async (ctx, change) => {
  if (change.operation === "insert") {
    const newBlockFid = parseFid(change.newDoc.fid, "blocks");
    // Try to fetch block with same fid - which will throw if there's multiple. Note that at the time of running this query the new doc is returned by the query
    await _getBlockByFid(ctx, {
      blockFid: newBlockFid,
    });
  } else if (change.operation === "update") {
    // Throw an error if the fid is being updated
    if (change.oldDoc.fid !== change.newDoc.fid) {
      throw new ConvexError("Block FID cannot be updated");
    }
  }
});
Was this page helpful?