Skip to content

Commit

Permalink
fix: guarantee single write of length prefixed data
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jan 30, 2024
1 parent 57d12f2 commit e5fdd3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
14 changes: 2 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"abortable-iterator": "^5.0.1",
"denque": "^2.1.0",
"it-length-prefixed": "^9.0.4",
"it-map": "^3.0.5",
"it-merge": "^3.0.3",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
Expand Down
8 changes: 3 additions & 5 deletions src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { abortableSource } from 'abortable-iterator'
import { encode, decode } from 'it-length-prefixed'
import map from 'it-map'
import merge from 'it-merge'
import { pipe } from 'it-pipe'
import { pushable, type Pushable } from 'it-pushable'
Expand Down Expand Up @@ -30,12 +31,9 @@ export class OutboundStream {

pipe(
abortableSource(
merge<Uint8Array | Uint8ArrayList>(
merge(
this.lpPushable,
pipe(
this.pushable,
(source) => encode(source)
)
map(this.pushable, buf => encode.single(buf))
), this.closeController.signal, { returnOnAbort: true }
),
this.rawStream
Expand Down

0 comments on commit e5fdd3e

Please sign in to comment.