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

Docs: write that users should call client.invoke({ _: 'close' }) instead of client.destroy() in most cases #88

Closed
Bannerets opened this issue Oct 7, 2020 · 0 comments

Comments

@Bannerets
Copy link
Owner

Bannerets commented Oct 7, 2020

tdlib/td#594 (comment), tdlib/td#771 (comment):

This is a sanity check that fires when app tries to destroy a client, which is still used in other thread by td_json_client_receive. You must first stop to use the client and only after that you can call td_json_client_destroy.

The usual way to do that is to call the method close, then wait for updateAuthoriationState with state authorizationStateClosed, stop calling td_json_client_receive and call td_json_client_destroy.

TDLib doesn't allow to call td_json_client_destroy while td_json_client_receive is running in another thread. It can happen in tdl, since it uses libuv threadpool to asynchronously call those methods.

So await client.invoke({ _: 'close' }) should be used instead of client.destroy() (which just calls internal td_json_client_destroy). tdl will call destroy automatically when it receives authorizationStateClosed.

Maybe client.destroy should be removed from the public interface in the next major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant