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

retry_execute can not handle TransportQueryError #472

Closed
PaleNeutron opened this issue Mar 1, 2024 · 1 comment
Closed

retry_execute can not handle TransportQueryError #472

PaleNeutron opened this issue Mar 1, 2024 · 1 comment
Labels
type: bug An issue or pull request relating to a bug type: documentation An issue or pull request for improving or updating the documentation

Comments

@PaleNeutron
Copy link

PaleNeutron commented Mar 1, 2024

Describe the bug

See here, user defined retry_execute wraps only self._execute . I have a poor quality backend which will return error on random.

So I want to catch all exceptions include TransportQueryError. But current framework won't work.

gql/gql/client.py

Lines 1628 to 1644 in 48bb94c

result = await self._execute(
document,
variable_values=variable_values,
operation_name=operation_name,
serialize_variables=serialize_variables,
parse_result=parse_result,
**kwargs,
)
# Raise an error if an error is returned in the ExecutionResult object
if result.errors:
raise TransportQueryError(
str_first_element(result.errors),
errors=result.errors,
data=result.data,
extensions=result.extensions,
)

BTW, current document is a little misleading:

# Here Only 3 tries for execute calls
retry_execute = backoff.on_exception(
    backoff.expo,
    Exception,
    max_tries=3,
    giveup=lambda e: isinstance(e, TransportQueryError),
)
session = await client.connect_async(
    reconnecting=True,
    retry_execute=retry_execute,
)

Users like me will believe remove giveup keyword will alllow it retry on TransportQueryError

@leszekhanusz leszekhanusz added type: bug An issue or pull request relating to a bug type: documentation An issue or pull request for improving or updating the documentation labels Mar 1, 2024
@leszekhanusz
Copy link
Collaborator

You're right, the documentation is misleading. The giveup argument is not needed here.
It is only useful in the subscribe case below as it uses the outer method there.

I made some changes in the documentation in PR #473 which should be clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug type: documentation An issue or pull request for improving or updating the documentation
Projects
None yet
Development

No branches or pull requests

2 participants