Skip to content

Commit 1fce957

Browse files
authored
chore: log invalid buffer (libp2p#30)
1 parent 3caf904 commit 1fce957

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/multistream.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import type { Source } from 'it-stream-types'
1313
import type { Reader } from 'it-reader'
1414
import type { MultistreamSelectInit } from '.'
1515
import { MAX_PROTOCOL_LENGTH } from './constants.js'
16+
import { logger } from '@libp2p/logger'
17+
18+
const log = logger('libp2p:mss')
1619

1720
const NewLine = uint8ArrayFromString('\n')
1821

@@ -83,6 +86,7 @@ export async function read (reader: Reader, options?: AbortOptions): Promise<Uin
8386
}
8487

8588
if (buf.get(buf.byteLength - 1) !== NewLine[0]) {
89+
log.error('Invalid mss message - missing newline - %s', buf.subarray())
8690
throw errCode(new Error('missing newline'), 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE')
8791
}
8892

0 commit comments

Comments
 (0)