Skip to content

edge case when write is called after pipe, but in the same tick. #4

@dominictarr

Description

@dominictarr

what if there is a write to the buffered stream later in the same tick as it has been piped, but before it has emitted it's chunks.
those chunks will be written out of order.

var b = new (require('morestreams').BufferedStream)()

b.write('1\n')
b.write('2\n')
b.write('3\n')
b.pipe(process.stdout, {end: false})
b.write('4\n')
b.write('5\n')
b.write('6\n')

gives output:

4
5
6
1
2
3

I think that it is correct to emit the chunks in the next tick, but incoming writes should be buffered until the buffered chunks have been emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions