Skip to content

Commit d7940c2

Browse files
Fix #815, TaskCanceledException when calling service from Dispose(Async) by avoiding Result-Handling task from being cancelled (#816)
1 parent edb8f3c commit d7940c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ private async Task<Task<HassMessage>> SendCommandAsyncInternal<T>(T command, Can
7676
// this task will be returned and handled by caller
7777
var resultEvent = _hassMessageSubject
7878
.Where(n => n.Type == "result" && n.Id == command.Id)
79-
.FirstAsync().ToTask(cancelToken);
79+
.FirstAsync().ToTask(CancellationToken.None);
80+
// We dont want to pass the incoming CancellationToken here because it will throw a TaskCanceledException
81+
// when calling services from an Apps Dispose(Async) and hide possible actual exceptions
8082

8183
await _transportPipeline.SendMessageAsync(command, cancelToken);
8284

0 commit comments

Comments
 (0)