Skip to content
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

How to handle incomplete streams? #43

Open
corneliusroemer opened this issue Sep 11, 2024 · 0 comments
Open

How to handle incomplete streams? #43

corneliusroemer opened this issue Sep 11, 2024 · 0 comments

Comments

@corneliusroemer
Copy link

corneliusroemer commented Sep 11, 2024

Is there a way to detect if an ndjson stream is terminated prematurely by the server?

Assume a server tries to stream the following ndjson:

 {"some":"thing"}
 {"foo":17,"bar":false,"quux":true}
 {"may":{"include":"nested","objects":["and","arrays"]}}

but due to server error, aborts prematurely, after sending the first 2 lines.

In JSON, this is trivially detected:

[
 {"some":"thing"},
 {"foo":17,"bar":false,"quux":true},

was obviously aborted prematurely.

However, this is not at all clear for the equivalent ndjson:

 {"some":"thing"}
 {"foo":17,"bar":false,"quux":true}

Could the spec be updated to indicate how to handle this? How can one indicate that the stream is complete? A closing sentinel could be used for example, e.g. 2 empty lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant