Skip to content

Commit e2016ac

Browse files
committed
Merge branch 'dev'
2 parents b4e4f4f + 454aee8 commit e2016ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ws_js.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
// Conn provides a wrapper around the browser WebSocket API.
4343
type Conn struct {
4444
noCopy noCopy
45-
ws wsjs.WebSocket
45+
ws wsjs.WebSocket
4646

4747
// read limit for a message in bytes.
4848
msgReadLimit xsync.Int64
@@ -138,7 +138,8 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
138138
if err != nil {
139139
return 0, nil, fmt.Errorf("failed to read: %w", err)
140140
}
141-
if int64(len(p)) > c.msgReadLimit.Load() {
141+
readLimit := c.msgReadLimit.Load()
142+
if readLimit >= 0 && int64(len(p)) > readLimit {
142143
err := fmt.Errorf("read limited at %v bytes", c.msgReadLimit.Load())
143144
c.Close(StatusMessageTooBig, err.Error())
144145
return 0, nil, err

0 commit comments

Comments
 (0)