Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pipe muxer/connection input/output streams in parallel #1491

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/upgrader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { logger } from '@libp2p/logger'
import errCode from 'err-code'
import * as mss from '@libp2p/multistream-select'
import { pipe } from 'it-pipe'
import { codes } from './errors.js'
import { createConnection } from '@libp2p/connection'
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
Expand Down Expand Up @@ -466,7 +465,12 @@ export class DefaultUpgrader extends EventEmitter<UpgraderEvents> implements Upg
}

// Pipe all data through the muxer
pipe(upgradedConn, muxer, upgradedConn).catch(log.error)
void Promise.all([
muxer.sink(upgradedConn.source),
upgradedConn.sink(muxer.source)
]).catch(err => {
log.error(err)
})
}

const _timeline = maConn.timeline
Expand Down