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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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