Skip to content

Commit e5fdd3e

Browse files
committed
fix: guarantee single write of length prefixed data
1 parent 57d12f2 commit e5fdd3e

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

package-lock.json

Lines changed: 2 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"abortable-iterator": "^5.0.1",
8282
"denque": "^2.1.0",
8383
"it-length-prefixed": "^9.0.4",
84+
"it-map": "^3.0.5",
8485
"it-merge": "^3.0.3",
8586
"it-pipe": "^3.0.1",
8687
"it-pushable": "^3.2.3",

src/stream.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { abortableSource } from 'abortable-iterator'
22
import { encode, decode } from 'it-length-prefixed'
3+
import map from 'it-map'
34
import merge from 'it-merge'
45
import { pipe } from 'it-pipe'
56
import { pushable, type Pushable } from 'it-pushable'
@@ -30,12 +31,9 @@ export class OutboundStream {
3031

3132
pipe(
3233
abortableSource(
33-
merge<Uint8Array | Uint8ArrayList>(
34+
merge(
3435
this.lpPushable,
35-
pipe(
36-
this.pushable,
37-
(source) => encode(source)
38-
)
36+
map(this.pushable, buf => encode.single(buf))
3937
), this.closeController.signal, { returnOnAbort: true }
4038
),
4139
this.rawStream

0 commit comments

Comments
 (0)