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

fix: Only call getResumptionRequestFn once #1593

Merged
merged 7 commits into from
May 9, 2024

Conversation

danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented May 2, 2024

Source code changes

The current code calls getResumptionRequestFn twice when the result from the first call can be reused. For clients implementing retries, we only want one call to getResumptionRequestFn to be done per request because we don’t want the state that getResumptionRequestFn relies on to be modified twice.

This change intends to reuse the result from the first call to getResumptionRequestFn so that getResumptionRequestFn is only called once.

Test changes

The resumption function is wrapped in sinon.spy so that its call count can be measured in an existing test. The call count is later tested to ensure its value is 1.

The current code calls getResumptionRequestFn twice when the result from the first call can be reused. For clients implementing retries, we only want one call to getResumptionRequestFn to be done per request because we don’t want the state that getResumptionRequestFn relies on to be modified twice.
@danieljbruce danieljbruce requested review from a team as code owners May 2, 2024 20:41
Copy link

conventional-commit-lint-gcf bot commented May 2, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label May 2, 2024
@leahecole leahecole self-assigned this May 3, 2024
@danieljbruce
Copy link
Contributor Author

Upon further inspection of this, it looks like the state updates need to be done earlier in the shouldRetryFn so this is not as important as I originally thought because now getResumptionRequestFn will not update state. Still though, other libraries might be updating the resumption state in getResumptionRequestFn so maybe this still has value.

@leahecole
Copy link
Contributor

If tests are passing, this seems good to me, but I think we should get #1592 merged first just to make sure there's no unexpected side effects of it

@leahecole leahecole added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 8, 2024
@leahecole leahecole removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 8, 2024
@leahecole
Copy link
Contributor

leahecole commented May 8, 2024

Teat failures likely not related to this PR. Will try rerunning in a bit

Test failures are part of this issue

@leahecole
Copy link
Contributor

Upon further inspection of this, it looks like the state updates need to be done earlier in the shouldRetryFn so this is not as important as I originally thought because now getResumptionRequestFn will not update state. Still though, other libraries might be updating the resumption state in getResumptionRequestFn so maybe this still has value.

I think this does have value and when I was going through the code, I honestly think that the original way this was written was likely a mistake because we don't utilize the resumptionRetryArgument other than to check if it's defined - that feels wrong - so I think this is totally reasonable

@leahecole leahecole added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 9, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 9, 2024
@leahecole leahecole added the kokoro:run Add this label to force Kokoro to re-run the tests. label May 9, 2024
@leahecole leahecole added the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2024
@leahecole leahecole merged commit e1755a9 into googleapis:main May 9, 2024
19 checks passed
@release-please release-please bot mentioned this pull request May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kokoro:run Add this label to force Kokoro to re-run the tests. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants