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

CTL + C cannot stop #496

Closed
tingfeng-key opened this issue Jan 16, 2022 · 3 comments · Fixed by #499
Closed

CTL + C cannot stop #496

tingfeng-key opened this issue Jan 16, 2022 · 3 comments · Fixed by #499
Assignees
Labels
K-bug Kind: bug

Comments

@tingfeng-key
Copy link

tingfeng-key commented Jan 16, 2022

When a network error occurs, it cannot be stopped through CTL + C, and it will cycle all the time.
And when the network is normal, CTL + C will stop service very slowly. Can you optimize it?

image

Meta

  • teloxide version: 0.5.3
  • rustc version: 1.57.0
@tingfeng-key tingfeng-key added the K-bug Kind: bug label Jan 16, 2022
@p0lunin
Copy link
Collaborator

p0lunin commented Jan 16, 2022

#470 changes a little update processing. Can you check if the bug is reproducible with https://github.com/teloxide/teloxide/tree/dispatching2?

@tingfeng-key
Copy link
Author

#470 changes a little update processing. Can you check if the bug is reproducible with https://github.com/teloxide/teloxide/tree/dispatching2?

Still the same

@WaffleLapkin
Copy link
Member

So, this is a bug in the polling implementation:

if flag.is_stopped() {
let mut req = bot.get_updates().offset(*offset).timeout(0).limit(1);
req.payload_mut().allowed_updates = allowed_updates.take();
return match req.send().await {
Ok(_) => None,
Err(err) => Some((Either::Left(stream::once(ready(Err(err)))), state)),
};
}

When stopping we call get_updates one last time to not receive the same updates next time. But if this request fails we return an error and do not stop until the call succeeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
K-bug Kind: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants