Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable submit button on click to prevent race conditions #10

Open
Timo614 opened this issue Dec 21, 2015 · 1 comment
Open

Disable submit button on click to prevent race conditions #10

Timo614 opened this issue Dec 21, 2015 · 1 comment
Labels

Comments

@Timo614
Copy link

Timo614 commented Dec 21, 2015

We have a few areas of logic where we're ending up bypassing the validations and hitting the unique indexes on the db due to a race condition.

The way the logic works is:

  1. Submit button is pressed
  2. Model validation is checked against the db if there already exists a record
  3. Model is committed to the db

When the user is able to mash the submit button multiple times two requests can make it past step 2 and reach step 3 in tandem. The second request fails because of the unique index so it's not too pressing but the second response is an error condition so the form for the user may mention that.

Should be a simple fix: after the form is submitted for any API action disable the submit button until a response from the server is returned. This prevents the user from entering this state.

Areas where we've noticed this happening:

  1. Contacts API
  2. Contests API
@Timo614 Timo614 added the bug label Dec 21, 2015
@Timo614
Copy link
Author

Timo614 commented Dec 21, 2015

Not a huge rush to address as it's harmless and somewhat rare -- just adding so we know to do in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant