-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this by any chance also fix #271?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... you tried or guessing? I'm thinking it might...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.