Skip to content

Commit d464bd7

Browse files
committed
test(py): add exhaustive bug-bash and real Firestore E2E test suites for FirestoreSessionStore
1 parent c775ac6 commit d464bd7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • py/packages/genkit-google-cloud/src/genkit_google_cloud/session_store

py/packages/genkit-google-cloud/src/genkit_google_cloud/session_store/firestore.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ async def on_snapshot_status_change(self, snapshot_id: str) -> asyncio.Queue[Sna
164164
current = await self.read_snapshot(snapshot_id)
165165
is_first = snapshot_id not in self.subs
166166
q = await subscribe(self.subs, snapshot_id, current)
167-
# Firestore listener keeps cross-instance abort working for detached turns.
167+
if current is not None and current.status in TERMINAL_STATUSES:
168+
await q.put(None)
169+
self.subs.pop(snapshot_id, None)
170+
return q
168171
if is_first and (current is None or current.status not in TERMINAL_STATUSES):
169172
try:
170173
self.start_listener(snapshot_id)
@@ -233,7 +236,7 @@ async def list_session_snapshots(self, session_id: str) -> list[SessionSnapshot]
233236
def start_listener(self, snapshot_id: str) -> None:
234237
"""Start a Firestore real-time listener for status changes on a snapshot."""
235238
ref = self.snapshot_ref(snapshot_id)
236-
if not hasattr(ref, 'on_snapshot'):
239+
if isinstance(self.client, firestore.AsyncClient) or not hasattr(ref, 'on_snapshot'):
237240
if self.sync_client is None:
238241
self.sync_client = firestore.Client(
239242
project=self.client.project,

0 commit comments

Comments
 (0)