project-receptor / python-receptor

Project Receptor is a flexible multi-service relayer with remote execution and orchestration capabilities linking controllers with executors across a mesh of nodes.
Other
32 stars 21 forks source link

Unicode 'invalid start byte' error sometimes #201

Open ghjm opened 4 years ago

ghjm commented 4 years ago

Tracebacks similar to the following are produced intermittently while performing receptor operations:

Traceback (most recent call last):
  File "/home/graham/git/receptor/receptor/connection/base.py", line 62, in receive
    await self.buf.put(msg)
  File "/home/graham/git/receptor/receptor/messages/framed.py", line 245, in put
    await self.consume(data)
  File "/home/graham/git/receptor/receptor/messages/framed.py", line 267, in consume
    await self.finish()
  File "/home/graham/git/receptor/receptor/messages/framed.py", line 283, in finish
    FramedMessage(msg_id=self.current_frame.msg_id, header=json.load(self.bb))
  File "/usr/lib64/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib64/python3.7/json/__init__.py", line 343, in loads
    s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8c in position 4080: invalid start byte

I don't have a reliable reproducer yet but it seems to happen more often when there are a larger number of communicating peers.

jhjaggars commented 4 years ago

https://github.com/project-receptor/receptor/blob/devel/receptor/connection/base.py#L109-L111

I think this section might be the issue.

ghjm commented 4 years ago

Is this as simple as changing ensure_future to wait_for? Or is there more to it?

jhjaggars commented 4 years ago

It used to be await.

I changed it due to high latency, but didn't consider out of order messages (duh).