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

Logging in lazy sequences may interfere with output of Content-Type: application/edn #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nvlass
Copy link

@nvlass nvlass commented Feb 5, 2023

The case addressed in this PR is the following:

  1. The request handler response a lazy sequence (i.e. a map of some function function-with-logs on some range).
  2. The function-with-logs does some logging (either with prns or with clojure.tools.logging)
  3. The sequence is not realised until we read the body, in which case the edn output is mixed with the output of the logging in lazy sequence.

This can be easily avoided if all such responses are realised with a doall, so this pull request might not be a case at all. Forgetting to realise the sequences can, however, result in hard to spot errors.

The solution is not optimal, since it essentially replicates the functionality of pr and pr-on from clojure.core. Perhaps it should also include some tests from clojure.core to ensure that the function remains consistent with pr-str.

Commits:

  • Add pr-to-writer in edn.clj, Add test for lazy sequences

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

Successfully merging this pull request may close these issues.

None yet

1 participant