Skip to content

Commit deae32e

Browse files
condronjoshkempner
authored andcommitted
Ensure reads match listeners on missing stream handling
1 parent b52080b commit deae32e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/ReactiveDomain.Foundation/StreamStore/StreamReader.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ public virtual bool Read(
151151
Ensure.Nonnegative((long)checkpoint, nameof(checkpoint));
152152
if (count != null)
153153
Ensure.Positive((long)count, nameof(count));
154-
if (!ValidateStreamName(streamName))
155-
throw new ArgumentException("Stream not found.", streamName);
156-
154+
if (!ValidateStreamName(streamName))
155+
return false;
156+
157157
_cancelled = false;
158158
FirstEventRead = false;
159159
StreamName = streamName;
@@ -191,8 +191,17 @@ public virtual bool Read(
191191
/// <param name="streamName">The stream name to validate.</param>
192192
public bool ValidateStreamName(string streamName)
193193
{
194-
var currentSlice = _streamStoreConnection.ReadStreamForward(streamName, 0, 1);
195-
return !(currentSlice is StreamDeletedSlice);
194+
try
195+
{
196+
var result = _streamStoreConnection.ReadStreamForward(streamName, 0, 1);
197+
198+
return result.GetType() == typeof(StreamEventsSlice);
199+
}
200+
catch (Exception)
201+
{
202+
return false;
203+
}
204+
196205
}
197206

198207
protected virtual void EventRead(RecordedEvent recordedEvent)

0 commit comments

Comments
 (0)