LuizL
Convex Community17mo ago
3 replies
Luiz

Buffered queue race

Objective: Concatenate incoming messages and process them 5 seconds after the last message is received.

Solution: Check if a "processing" task is already scheduled. If so, cancel the existing task, concatenate the new message, and reschedule the task.

Expectation: Convex should internally handle race conditions in the scheduler, ensuring that no more than one processing task is ever scheduled at a time.

Issue: When messages arrive at a slow pace, everything works as expected. However, when messages arrive simultaneously, a race condition occurs, resulting in multiple scheduled tasks.

Test code:
Was this page helpful?