Jinho KimJ
Convex Community2y ago
8 replies
Jinho Kim

How can I use timeout in mutation?

I have set up the following configuration using Clerk webhooks:

1. When an organization is created, a Document of type "workspace" is also created with the same data.
2. When an organization membership is created, a Document of type "workspace membership" is generated.

The issue arises when creating a workspace, as both steps 1 and 2 occur simultaneously. During the process of creating a workspace through step 1, if step 2 is triggered before the Doc<"workspace"> is created, it results in an error because the Doc<"workspace_membership"> cannot be created without the workspace existing.

To address this, I implemented code that uses a timeout to wait until the workspace is created before proceeding with creating the workspace membership.

However, using a timeout within the mutation has led to errors. Is there a better way to handle this situation?
image.png
Was this page helpful?