Skip to content

Use axios CancelToken to prevent race conditions

What does this MR do?

This MR improves UsernameValidator so invalid states are not reachable. It is achieved by removing race conditions happening due to multiple axios requests being in progress at the same time in some situations (poor networking conditions or pace of typing matching debounce timeout).

Use axios.CancelToken to cancel pending request on input event. Use WeakMap to store cancel token sources with related dom elements (there is one validator instance on page, handling all username inputs, did not want to change that). Move hiding pending message to finally so it is not visible if request is not in progress (either because it finished or was cancelled).

Please see related issue for more details.

I would like this MR to be a part of my GitLab Hackathon contribution. /cc @cbacharakis

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #296763

Edited by Marcin Majkowski

Merge request reports

Loading