Skip to content

Commit 18679ae

Browse files
committed
Fix conpty
1 parent 0ccc7b6 commit 18679ae

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

agent/agent.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -445,26 +445,26 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
445445
}
446446
_ = conn.Close()
447447
})
448-
// This cannot use a JSON decoder, since that can
449-
// buffer additional data that is required for the PTY.
450-
rawLen := make([]byte, 2)
451-
_, err = conn.Read(rawLen)
452-
if err != nil {
453-
continue
454-
}
455-
length := binary.LittleEndian.Uint16(rawLen)
456-
data := make([]byte, length)
457-
_, err = conn.Read(data)
458-
if err != nil {
459-
continue
460-
}
461-
var msg codersdk.ReconnectingPTYInit
462-
err = json.Unmarshal(data, &msg)
463-
if err != nil {
464-
continue
465-
}
466448
_ = a.trackConnGoroutine(func() {
467449
defer close(closed)
450+
// This cannot use a JSON decoder, since that can
451+
// buffer additional data that is required for the PTY.
452+
rawLen := make([]byte, 2)
453+
_, err = conn.Read(rawLen)
454+
if err != nil {
455+
return
456+
}
457+
length := binary.LittleEndian.Uint16(rawLen)
458+
data := make([]byte, length)
459+
_, err = conn.Read(data)
460+
if err != nil {
461+
return
462+
}
463+
var msg codersdk.ReconnectingPTYInit
464+
err = json.Unmarshal(data, &msg)
465+
if err != nil {
466+
return
467+
}
468468
_ = a.handleReconnectingPTY(ctx, logger, msg, conn)
469469
})
470470
}

0 commit comments

Comments
 (0)