File tree Expand file tree Collapse file tree
stagehand-java-core/src/main/kotlin/com/browserbase/api/core/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11configured_endpoints : 8
22openapi_spec_url : https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-573d364768ac1902ee5ed8b2485d3b293bda0ea8ff7898aef1a3fd6be79b594a.yml
33openapi_spec_hash : 107ec840f4330885dd2232a05a66fed7
4- config_hash : ab1c1122e862f9bdb6db4df36d489701
4+ config_hash : 0209737a4ab2a71afececb0ff7459998
Original file line number Diff line number Diff line change @@ -18,11 +18,22 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
1818internal 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())
You can’t perform that action at this time.
0 commit comments