Skip to content

Commit 55832db

Browse files
feat: Revert broken finished SSE yield config
1 parent 12addb4 commit 55832db

2 files changed

Lines changed: 13 additions & 2 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: ab1c1122e862f9bdb6db4df36d489701
4+
config_hash: 0209737a4ab2a71afececb0ff7459998

stagehand-java-core/src/main/kotlin/com/browserbase/api/core/handlers/SseHandler.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
1818
internal fun sseHandler(jsonMapper: JsonMapper): Handler<StreamResponse<SseMessage>> =
1919
streamHandler { response, lines ->
2020
val state = SseState(jsonMapper)
21+
var done = false
2122
for (line in lines) {
23+
// Stop emitting messages, but iterate through the full stream.
24+
if (done) {
25+
continue
26+
}
27+
2228
val message = state.decode(line) ?: continue
2329

2430
when {
25-
message.data.startsWith("{\"data\":{\"status\":\"finished\"") -> yield(message)
31+
message.data.startsWith("{\"data\":{\"status\":\"finished\"") -> {
32+
// In this case we don't break because we still want to iterate through the full
33+
// stream.
34+
done = true
35+
continue
36+
}
2637
message.data.startsWith("error") -> {
2738
throw SseException.builder()
2839
.statusCode(response.statusCode())

0 commit comments

Comments
 (0)