Skip to content

Encoding errors while sending aren't thrown because the sending task is started as fire and forget #188

@SoerenBusse

Description

@SoerenBusse

Hey there,

I've incorrectly passed a string instead of a message to a grpc field. This will result in an exception which is thrown during encoding in the __bytes__ method (https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/__init__.py#L634). This method throws an exception that it cannot encode a string as a message.

However the user never sees the exception, because the sending task is started as fire and forget, without handling the exception case. This will result in hidden exceptions. The user only notices that the program doesn't work as expected or it feels like the program has hung up:

sending_task = asyncio.ensure_future(
    self._send_messages(stream, request_iterator)
)

https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/grpc/grpclib_client.py#L153

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions