My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Prevent Race condition in REST api

Khalil Mohammad Mirza's photo
Khalil Mohammad Mirza
·Feb 28, 2020

I have an api that creates a signing session between two users. This api checks if there is an existing signing session or there was signing request in past. It uses that session instead of creating new.

Problem here is that if both users create separate signing session. This is only possible if both user start near instantaneously.

I am thinking of either adding message queue strategy or using socket instead http call.

I am also worried that socket strategy will also introduce race conditions.

Message Queue strategy sound nice but we are not using Message Queue strategy anywhere in project. I do not want to add new technologies into project unless existing can not server my need.