Skip to content

Commit bcbd0d1

Browse files
feat: [STG-1607] Yield finished SSE event instead of silently dropping it
1 parent 5c0e28e commit bcbd0d1

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-573d364768ac1902ee5ed8b2485d3b293bda0ea8ff7898aef1a3fd6be79b594a.yml
33
openapi_spec_hash: 107ec840f4330885dd2232a05a66fed7
4-
config_hash: 0209737a4ab2a71afececb0ff7459998
4+
config_hash: ab1c1122e862f9bdb6db4df36d489701

src/SSEStream.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ private function parsedGenerator(): \Generator
2929
return;
3030
}
3131

32-
$done = false;
3332
foreach ($this->stream as $row) {
34-
// @phpstan-ignore if.alwaysFalse
35-
if ($done) {
36-
// Iterate through the whole stream
37-
continue;
38-
}
39-
4033
switch ($row['event'] ?? null) {
4134
case null:
4235
if ($data = $row['data'] ?? '') {
@@ -50,7 +43,9 @@ private function parsedGenerator(): \Generator
5043

5144
if ($data = $row['data'] ?? '') {
5245
if (str_starts_with($data, needle: '{"data":{"status":"finished"')) {
53-
$done = true;
46+
$decoded = Util::decodeJson($data);
47+
48+
yield Conversion::coerce($this->convert, value: $decoded);
5449

5550
continue;
5651
}

0 commit comments

Comments
 (0)