Skip to content

retry_execute can not handle TransportQueryError #472

Closed
@PaleNeutron

Description

@PaleNeutron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bugtype: documentationAn issue or pull request for improving or updating the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions