Skip to content

Commit d5ffd2d

Browse files
feat: [STG-1607] Yield finished SSE event instead of silently dropping it
1 parent 85b5b46 commit d5ffd2d

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

.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

lib/stagehand/internal/stream.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ class Stream
1616
# @return [Enumerable<generic<Elem>>]
1717
private def iterator
1818
# rubocop:disable Metrics/BlockLength
19+
# rubocop:disable Lint/DuplicateBranch
1920
@iterator ||= Stagehand::Internal::Util.chain_fused(@stream) do |y|
20-
consume = false
21-
2221
@stream.each do |msg|
23-
next if consume
24-
2522
case msg
2623
in {data: String => data} if data.start_with?("{\"data\":{\"status\":\"finished\"")
27-
consume = true
28-
next
24+
decoded = JSON.parse(data, symbolize_names: true)
25+
unwrapped = Stagehand::Internal::Util.dig(decoded, @unwrap)
26+
y << Stagehand::Internal::Type::Converter.coerce(@model, unwrapped)
2927
in {data: String => data} if data.start_with?("error")
3028
decoded = Kernel.then do
3129
JSON.parse(data, symbolize_names: true)
@@ -49,6 +47,7 @@ class Stream
4947
end
5048
end
5149
end
50+
# rubocop:enable Lint/DuplicateBranch
5251
# rubocop:enable Metrics/BlockLength
5352
end
5453
end

0 commit comments

Comments
 (0)