diff --git a/src/identify/index.ts b/src/identify/index.ts index 04da9c0600..4845584e50 100644 --- a/src/identify/index.ts +++ b/src/identify/index.ts @@ -2,7 +2,6 @@ import { logger } from '@libp2p/logger' import errCode from 'err-code' import * as lp from 'it-length-prefixed' import { pipe } from 'it-pipe' -import drain from 'it-drain' import first from 'it-first' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { multiaddr, protocols } from '@multiformats/multiaddr' @@ -191,16 +190,14 @@ export class IdentifyService implements Startable { // make stream abortable const source = abortableDuplex(stream, timeoutController.signal) - await pipe( + await source.sink(pipe( [Identify.encode({ listenAddrs, signedPeerRecord, protocols })], - lp.encode(), - source, - drain - ) + lp.encode() + )) } catch (err: any) { // Just log errors log.error('could not push identify update to peer', err) @@ -430,12 +427,8 @@ export class IdentifyService implements Startable { // make stream abortable const source = abortableDuplex(stream, timeoutController.signal) - await pipe( - [message], - lp.encode(), - source, - drain - ) + const msgWithLenPrefix = pipe([message], lp.encode()) + await source.sink(msgWithLenPrefix) } catch (err: any) { log.error('could not respond to identify request', err) } finally {