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

Quick calls to connect() results in thread leaks #918

Open
AndyTWF opened this issue Feb 9, 2023 · 1 comment
Open

Quick calls to connect() results in thread leaks #918

AndyTWF opened this issue Feb 9, 2023 · 1 comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@AndyTWF
Copy link
Contributor

AndyTWF commented Feb 9, 2023

Discovered inadvertently during the investigation of #917.

If you use the autoconnect option in ClientOptions and also call connect on the ably instance, a race condition exists whereby threads are leaked from the underlying websocket handler.

This is because starting connections discards the current transport, calling transport.close(). The underlying websocket library only cleans up threads properly if the write thread (which is started by the read thread) isn't null.

With quick calls to connect, you can end up in a case where the write thread isn't yet started. This means that when the transport is closed, the read thread is left running, the write thread gets created - and neither can be cleaned up.

The issue is complicated by the fact that connecting is an asynchronous state change.

┆Issue is synchronized with this Jira Task by Unito

@AndyTWF AndyTWF added the bug Something isn't working. It's clear that this does need to be fixed. label Feb 9, 2023
@sync-by-unito
Copy link

sync-by-unito bot commented Feb 9, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

1 participant