Skip to content

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

Open

Description

@AndyTWF

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

Activity

  1. added
    bugSomething isn't working. It's clear that this does need to be fixed.
    on Feb 9, 2023
  2. sync-by-unito commented on Feb 9, 2023

    @sync-by-unito

    ➤ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. It's clear that this does need to be fixed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions