Skip to content

Conversation

@bseto
Copy link

@bseto bseto commented Dec 9, 2025

according to the Limiter interface, successes will be given to ReportResult as err == nil.

In releaseConn it's given the err regardless of nil or non nil - expected
But with getConn, it is only given err if err != nil - not expected, this means we don't get success

I don't think this should be the behaviour because right before getConn is called, there's an Allow() call. I can't speak for everyone's use-case, but I'm setting Allow() to return true, and looking for a success call next - and this usually works - but sometimes the code gets stuck, and I think it's because in the case where Allow() returns true for a _getConn, if this function succeeds, ReportResult is not given the success

according to the interface, successes will be given to ReportResult as
err == nil.

In releaseConn it's given the err regardless of nil or non nil. But with
getConn, it is only given err if err != nil.

I don't think this should be the behaviour because right before getConn
is called, there's an Allow() call. I can't speak for everyone's
use-case, but I'm setting Allow() to return true, and looking for a
success call next - and this usually works - but sometimes I get stuck,
and I think it's because in the case where Allow() returns true for a
_getConn, if this succeeds, ReportResult is not given a success.
@jit-ci
Copy link

jit-ci bot commented Dec 9, 2025

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@bseto bseto marked this pull request as ready for review December 9, 2025 22:50
@ndyakov
Copy link
Member

ndyakov commented Dec 10, 2025

hello @bseto , thank you for opening this PR.
@ofekshenawa would you be able to take a look at it?

@ofekshenawa
Copy link
Collaborator

@bseto Could you please add a small test case (perhaps using a mock limiter) to verify that ReportResult is now correctly called on success? Also It would also be good to briefly confirm that this change won't introduce significant overhead or locking contention for standard limiters, given it will now run on every operation

@bseto bseto marked this pull request as draft December 10, 2025 21:48
@bseto
Copy link
Author

bseto commented Dec 10, 2025

Sorry nevermind. I see that Allow() is only called once. So if it gets the connection, then the success there is ignored because the function still has to run, and then the result of that function will determine the final success/failure to ReportResult.

@bseto bseto closed this Dec 10, 2025
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