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

qrcodemodel: Rate limit the emission of reselect auth mode events #513

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

3v1n0
Copy link
Collaborator

@3v1n0 3v1n0 commented Sep 5, 2024

When hitting the Enter key for a while, bubbletea sends lots of events and we may imply sending reselectAuthMode{} events faster than we can actually handle the cancellation/reauthModeSelection in the whole stack.

This never happened (ever) when using the example broker, but it may actually happen in a real world scenario where the broker may not cancel the requests quickly enough.

Do this instead of avoiding the handling of the reselectAuthMode event because it's better to prevent bubbletea to break our (fragile) system.

The change is already tested by authenticate_user_with_qr_code_after_many_regenerations test.

UDENG-4091

@3v1n0 3v1n0 requested a review from a team as a code owner September 5, 2024 04:49
@3v1n0 3v1n0 force-pushed the qrcode-rate-limit branch 7 times, most recently from 2f96976 to b04fb84 Compare September 6, 2024 18:11
Copy link
Member

@denisonbarbosa denisonbarbosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I have some suggestions, but nice work!

pam/internal/adapter/qrcodemodel.go Outdated Show resolved Hide resolved
pam/internal/adapter/qrcodemodel.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.65%. Comparing base (223a072) to head (f3fb9ec).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #513      +/-   ##
==========================================
- Coverage   84.75%   84.65%   -0.11%     
==========================================
  Files          79       79              
  Lines        6942     6948       +6     
  Branches       75       75              
==========================================
- Hits         5884     5882       -2     
- Misses        739      743       +4     
- Partials      319      323       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@denisonbarbosa denisonbarbosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Nice work!

When hitting the Enter key for a while, bubbletea sends lots of events
and we may imply sending reselectAuthMode{} events faster than we can
actually handle the cancellation/reauthModeSelection in the whole stack.

This never happened (ever) when using the example broker, but it may
actually happen in a real world scenario where the broker may not cancel
the requests quickly enough.

Do this instead of avoiding the handling of the reselectAuthMode event
because it's better to prevent bubbletea to break our (fragile) system.
@3v1n0 3v1n0 merged commit ceae541 into ubuntu:main Sep 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants