Skip to content

StreamReader reports null if no new events exist. #162

@dealproc

Description

@dealproc

In the following code snippet:

	private TaskCompletionSource _refreshTCS = null!;
	public Task RefreshAsync() {
		if (_refreshTCS != null)
			return _refreshTCS.Task;

		_refreshTCS = new();
		Task.Run(() => {
			using (var reader = _connection.GetReader($"{nameof(CartDetailsRm)}-ctor", Handle)) {
				reader.Read<Cart>(_cartId, () => Idle, checkpoint: _cartCheckpoint);
				// this seems like bad juju.  is this a bug?
				_cartCheckpoint = reader.Position is null
					? _cartCheckpoint
					: reader.Position;

				_refreshTCS.SetResult();
				_refreshTCS = null!;
			}
		});

		return _refreshTCS?.Task ?? Task.CompletedTask;
	}

In the event that the read from reader.Read<TAggregate>([id], () => Idle, checkpoint: ...) does not read anything new from the provided checkpoint, reader.Position reports null, when it should report the current position (in my opinion)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions