Only resolve lazy allowances if absolutely necessary #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've recently ran into weird Mox failures while running a lot of asynchronous tests that leverage lazy allowances resolution. After some investigation, I figured that
NimbleOwnership
resolves all lazy allowances every timeget_and_update
orfetch_owner
is called. Given that Mox runs a single global server, this results in a situation when a lazy allowance can be resolved at a random time simply because another tests was making a call to a different mock.Here's a failing Mox test for example
This PR aims to address this:
Changes:
lazy_calls
from the state. I don't believe it was actually read anywhere.revalidate_lazy_calls/2
withresolve_lazy_calls_for_key/2
. It will only resolve allowances for the given key.fetch_owner
code a little so that we would first attempt all owners and resolved allowances and only if nothing worked resolve lazy ones.Notes:
resolve_lazy_calls_for_key
's behaviour in a sense that it allows callbacks to "keep on giving". That means that resolution is never final and this check is not bullet-proof and a process can become an owner of a key it has allowance for. I'm not sure what the implications of this are though 😅