Skip to content

Commit 23ebcce

Browse files
committed
Refactor to use one lexer per connection
1 parent 43a0bf9 commit 23ebcce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/js/modules/k6/browser/common/connection.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ func (c *Connection) findTargetIDForLog(id target.SessionID) target.ID {
328328

329329
//nolint:funlen,gocognit,cyclop
330330
func (c *Connection) recvLoop() {
331+
decoder := jlexer.Lexer{}
331332
var buffer bytes.Buffer
332333
c.logger.Debugf("Connection:recvLoop", "wsURL:%q", c.wsURL)
333334
for {
@@ -352,7 +353,8 @@ func (c *Connection) recvLoop() {
352353
c.logger.Tracef("cdp:recv", "<- %s", buf)
353354

354355
var msg cdproto.Message
355-
c.decoder = jlexer.Lexer{Data: buf}
356+
decoder.Data = buf
357+
c.decoder = decoder
356358
msg.UnmarshalEasyJSON(&c.decoder)
357359
if err := c.decoder.Error(); err != nil {
358360
select {

0 commit comments

Comments
 (0)