[Go] Fixed streaming.#285
Conversation
Also rationalize the dotprompt package and make it easier to use.
| stream.on('end', () => { | ||
| resolver(RunActionResponseSchema.parse(JSON.parse(buffer))); | ||
| }); | ||
| stream.on('error', (err: Error) => { |
There was a problem hiding this comment.
No :( I didn't realize you filed an issue for this in JS but I've been running into the same issue with Go. Getting closer to fixing it but not quite there yet...
There was a problem hiding this comment.
Hmm... you tried or guessing? I'm thinking it might...
There was a problem hiding this comment.
I didn't try with your case but the case I'm trying to fix similarly crashes the process due to schema validation and it didn't fix it. We're throwing an exception and it's not caught anywhere so it makes sense that it crashes it, no?
| return err | ||
| } | ||
| if f, ok := w.(http.Flusher); ok { | ||
| f.Flush() |
There was a problem hiding this comment.
I'm surprised Transfer-Encoding: chunked header is not required... but appears to be the case: https://stackoverflow.com/questions/26769626/send-a-chunked-http-response-from-a-go-server
Streamed responses need to be flushed otherwise they will all be returned at the same time at the end. Also, streaming relies on newline characters so response JSON cannot be pretty-printed.