Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2] getDifference method is not invoked after the Gap raises in process_updates #4428

Open
3 tasks done
naztar0 opened this issue Aug 8, 2024 · 0 comments
Open
3 tasks done

Comments

@naztar0
Copy link

naztar0 commented Aug 8, 2024

Code that causes the issue

telethon/_impl/client/client/updates.py

def process_socket_updates(client: Client, all_updates: list[abcs.Updates]) -> None:
    if not all_updates:
        return

    for updates in all_updates:
        try:
            client._message_box.ensure_known_peer_hashes(updates, client._chat_hashes)
        except Gap:
            return

        try:
            result, users, chats = client._message_box.process_updates(
                updates, client._chat_hashes
            )
        except Gap:
            return

        extend_update_queue(client, result, users, chats)

Expected behavior

Invoke the get_difference method when required.

Actual behavior

The get_difference method is never invoked.

Traceback

No response

Telethon version

2

Python version

3.12

Operating system (including distribution name and version)

Windows 11

Other details

In situations where, when processing updates in the MessageBox.process_updates method, it is detected that self.seq + 1 < combined.seq_start, i.e. a signal that it is necessary to get the missed updates via getDifference, the request is just ignored, the missed updates aren't requested, and this leads to the fact that all subsequent incoming updates will also be ignored without firing any handlers.

At the same time, MessageBox implements methods for getting the difference, but they are not used anywhere. Therefore, as I understand it, you just haven't yet managed to implement this functionality.

In fact, I tried to fix this, but I don't understand what pattern you would stick to. It would be a separate task for asynchronous checking getting_diff_for/possible_gaps, or requesting the difference directly in process_socket_updates, or in client.py, or in net.py. However, it wouldn't work in process_socket_updates, because requesting inside asyncio.Lock leads to stuck. I'd like to know your opinion about this.

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant