async def _handle_goodbye(self, stream: INetStream) -> None:
    peer_id = stream.mplex_conn.peer_id
    self.logger.debug('Waiting for goodbye from %s', peer_id)
    try:
        goodbye = (await read_req(stream, Goodbye))
        has_error = False
    except (ReadMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, ReadMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    self.logger.debug('Received the goodbye message %s', goodbye)
    if (not has_error):
        (await stream.close())
    (await self.disconnect_peer(peer_id))
async def _handle_goodbye(self, stream: INetStream) -> None:
    peer_id = stream.mplex_conn.peer_id
    self.logger.debug('Waiting for goodbye from %s', peer_id)
    try:
        goodbye = (await read_req(stream, Goodbye))
        has_error = False
    except (ReadMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, ReadMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    self.logger.debug('Received the goodbye message %s', goodbye)
    if (not has_error):
        (await stream.close())
    (await self.disconnect_peer(peer_id))