packet-stream icon indicating copy to clipboard operation
packet-stream copied to clipboard

Drop received data after wrote end

Open staltz opened this issue 4 years ago • 1 comments

Similar to https://github.com/ssb-js/muxrpc/pull/77, this is @clehner's PR but I'm just putting it up here on GitHub.

PS: it seems that tests don't pass, so I'll mark this as draft.

staltz avatar Jan 19 '22 15:01 staltz

The tests are rather strange. They seem to actually depend on this behaviour where values will be written after a close.

The output inside read starts with end = true with the patch this is because all values are dropped while closing. The output without patch and a few console.logs:

# streams, close
closing b
writing values
not dropping!
b read 1 undefined
ok 14 should be strictly equal
not dropping!
b read 2 undefined
ok 15 should be strictly equal
not dropping!
b read 3 undefined
ok 16 should be strictly equal
not dropping!
b read 3 undefined
ok 17 should be strictly equal
not dropping!
b read 5 undefined
ok 18 should be strictly equal
b read null true
ok 19 should be truthy
closed b
ok 20 should be truthy

Also notice that the failing test expects the same output as the test below it (receive stream, then close) 🤔

arj03 avatar Jan 21 '22 11:01 arj03