# Buggy code
def on_blob(self, peer, blob):
    """
    Callback for when a MetadataBlob message comes in.

    :param peer: the peer that sent us the blob
    :param data: payload raw data
    """

    with db_session:
        md_list = self.metadata_store.process_compressed_mdblob(blob.raw_blob)
        # Check if the guy who send us this metadata actually has an older version of this md than
        # we do, and queue to send it back.

        reply_list = [
            md
            for md, result in md_list
            if (md and (md.metadata_type == CHANNEL_TORRENT))
            and (result == GOT_NEWER_VERSION)
        ]
        reply_blob = (
            entries_to_chunk(reply_list, maximum_payload_size)[0]
            if reply_list
            else None
        )
    if reply_blob:
        self.endpoint.send(
            peer.address,
            self.ezr_pack(self.NEWS_PUSH_MESSAGE, RawBlobPayload(reply_blob)),
        )


# Traceback (RuntimeError)
ERROR:Executor:********** TRIBLER CRASHED **********
ERROR:Executor:Tribler crashed after uptime of 338.184000015 sec! Stack trace: Traceback (most recent call last):
File "TriblerGUI\event_request_manager.py", line 135, in on_read_data
RuntimeError: [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: LZ4F_getFrameInfo failed with code: ERROR_frameType_unknown
lib\site-packages\twisted\internet\base.py:1243:run
lib\site-packages\twisted\internet\base.py:1252:mainLoop
lib\site-packages\twisted\internet\base.py:878:runUntilCurrent
lib\site-packages\twisted\internet\task.py:239:__call__
--- <exception caught here> ---
lib\site-packages\twisted\internet\defer.py:150:maybeDeferred
Tribler\Core\Libtorrent\LibtorrentMgr.py:611:_task_process_alerts
Tribler\Core\Libtorrent\LibtorrentMgr.py:407:process_alert
Tribler\Core\Libtorrent\__init__.py:17:invoke_func
Tribler\Core\Libtorrent\LibtorrentDownloadImpl.py:487:process_alert
Tribler\Core\Libtorrent\__init__.py:17:invoke_func
Tribler\Core\Libtorrent\LibtorrentDownloadImpl.py:627:on_torrent_finished_alert
Tribler\Core\Modules\gigachannel_manager.py:185:<lambda>
Tribler\Core\Modules\gigachannel_manager.py:115:on_channel_download_finished
Tribler\Core\Modules\MetadataStore\store.py:181:process_channel_dir
<auto generated wrapper of process_mdblob_file() function>:2:process_mdblob_file
lib\site-packages\pony\orm\core.py:515:new_func
Tribler\Core\Modules\MetadataStore\store.py:201:process_mdblob_file
<auto generated wrapper of process_compressed_mdblob() function>:2:process_compressed_mdblob
lib\site-packages\pony\orm\core.py:515:new_func
Tribler\Core\Modules\MetadataStore\store.py:205:process_compressed_mdblob
]

# Fixed code
def on_blob(self, peer, blob):
    """
    Callback for when a MetadataBlob message comes in.

    :param peer: the peer that sent us the blob
    :param data: payload raw data
    """

    with db_session:
        try:
            md_list = self.metadata_store.process_compressed_mdblob(blob.raw_blob)
        except RuntimeError:
            return
        # Check if the guy who send us this metadata actually has an older version of this md than
        # we do, and queue to send it back.

        reply_list = [
            md
            for md, result in md_list
            if (md and (md.metadata_type == CHANNEL_TORRENT))
            and (result == GOT_NEWER_VERSION)
        ]
        reply_blob = (
            entries_to_chunk(reply_list, maximum_payload_size)[0]
            if reply_list
            else None
        )
    if reply_blob:
        self.endpoint.send(
            peer.address,
            self.ezr_pack(self.NEWS_PUSH_MESSAGE, RawBlobPayload(reply_blob)),
        )