Skip to content

fix: Exception on server disconnect -> ServerDisconnect is not raised - #695

Merged
qdot merged 1 commit into
buttplugio:masterfrom
mortarroad:fix-dispose
Sep 20, 2026
Merged

qdot merged 1 commit into
buttplugio:masterfrom
mortarroad:fix-dispose

Conversation

@mortarroad

Copy link
Copy Markdown
Contributor

I get the following exception when stopping the server (Intiface Central 3.1.0 via the Stop button) while connected:

System.InvalidOperationException: A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled).
  at System.Threading.Tasks.Task.Dispose (System.Boolean disposing)
  at System.Threading.Tasks.Task.Dispose ()
  at Buttplug.Client.ButtplugWebsocketConnector.RunClientLoop (System.Threading.CancellationToken token) in Buttplug/Client/ButtplugWebsocketConnector.cs:135

This results in the ButtplugClient.ServerDisconnect event not being raised.


I think the Dispose was meant to set the task to "fire-and-forget". That can be achieved by just discarding the return value.

According to https://devblogs.microsoft.com/dotnet/do-i-need-to-dispose-of-tasks/, tasks do not need to be disposed anyway.

@CLAassistant

CLAassistant commented Jun 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@qdot
qdot merged commit 9d0cccb into buttplugio:master Sep 20, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants