Repro:
This error happens when you have more than one unread in a row.
A trace of what happens when running the repro. First add some logging in reader_types:
Then run the repro:
Proposed solution
The patch prevents two successive unreads by only unreading when necessary: at the end of the token.
The trace with the patch applied:
Thanks! merged