fix(dcl): discard in-flight subscribe results for unsubscribed tags; release the orphaned handle

This commit is contained in:
Joseph Doherty
2026-08-14 23:25:48 -04:00
parent b1de9dfdd4
commit 37f13e2eaa
3 changed files with 208 additions and 7 deletions
@@ -35,6 +35,13 @@ public sealed class FakeBatchDataConnection
public Func<Exception>? BatchSubscribeThrows;
/// <summary>When true, bulk reads never return until the caller's token cancels.</summary>
public bool HangReads;
/// <summary>
/// When set, <see cref="SubscribeBatchAsync"/> records the call and then parks until this
/// task completes, before producing its result rows. Lets a test hold a subscribe batch
/// in flight while it drives other messages into the actor (e.g. an unsubscribe that
/// races the completion).
/// </summary>
public Task? SubscribeGate;
/// <summary>Value returned for every readable tag.</summary>
public object? SeedValue = 42;
@@ -67,7 +74,7 @@ public sealed class FakeBatchDataConnection
}
/// <inheritdoc />
public Task<IReadOnlyList<TagSubscribeResult>> SubscribeBatchAsync(
public async Task<IReadOnlyList<TagSubscribeResult>> SubscribeBatchAsync(
IReadOnlyList<string> tagPaths, SubscriptionCallback callback, CancellationToken cancellationToken = default)
{
SubscribeBatches.Enqueue(tagPaths.ToList());
@@ -77,12 +84,15 @@ public sealed class FakeBatchDataConnection
if (BatchSubscribeThrows is { } factory)
throw factory();
if (SubscribeGate is { } gate)
await gate;
IReadOnlyList<TagSubscribeResult> rows = tagPaths
.Select(t => FailingTags.Contains(t)
? new TagSubscribeResult(t, false, null, "node not found")
: new TagSubscribeResult(t, true, $"sub-{Interlocked.Increment(ref _nextId)}", null))
.ToList();
return Task.FromResult(rows);
return rows;
}
/// <inheritdoc />