Spot the bug in the framed message reader

from Network programming
Python 3.14 intermediate 7 min 3 issues to find

Find the framing bugs in this generated reader.

Python
from struct import Struct

HEADER = Struct("!I")

def receive_message(sock):
    header = sock.recv(HEADER.size)
    (size,) = HEADER.unpack(header)
    payload = sock.recv(size)
    return payload.decode("utf-8")
Open in playground
Report an error