How should I unshift chunk?

37 views
Skip to first unread message

Bodo Kaiser

unread,
Mar 31, 2013, 8:14:51 AM3/31/13
to nod...@googlegroups.com
Hello,

I want to unshift chunk back on the source to reparse it later on.

Unfortunately this has brought me to following trap (I hope I have analyzed it correct):

1. source emits "readable" 
2. A listener calls next.read(0) to start reading
3. next._read() calls "source.unshift(chunk)"
4. because source is currently freeing its buffer it does not emit "readable"
5. without a new "readable" next does not parse anything again until we manually call "next.read(0)" again

Here is a gist which describes this: https://gist.github.com/bodokaiser/5280367

What else could I do to push back chunk I want to parse on the next "_read"?

Bodo

Michael Jackson

unread,
Mar 31, 2013, 11:28:06 PM3/31/13
to nod...@googlegroups.com
Have you tried this on node version 0.10.2? There were some bugs around the readable event that are now fixed.

--
Michael Jackson
@mjackson


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bodo Kaiser

unread,
Apr 1, 2013, 5:30:38 AM4/1/13
to nod...@googlegroups.com
Yes, I always update fast :)

Is actually now a bug or a behavior to avoid recalling read when read is actually not finished?

Bodo

You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/0d8sDT58LGU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages