Skip to content

Commit 5798948

Browse files
committed
fixup! ws_js: Update to match new close code
1 parent a9e9d67 commit 5798948

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

read.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
6464
// This function is idempotent.
6565
func (c *Conn) CloseRead(ctx context.Context) context.Context {
6666
c.closeReadMu.Lock()
67-
if c.closeReadCtx != nil {
67+
ctx2 := c.closeReadCtx
68+
if ctx2 != nil {
6869
c.closeReadMu.Unlock()
69-
return c.closeReadCtx
70+
return ctx2
7071
}
7172
ctx, cancel := context.WithCancel(ctx)
7273
c.closeReadCtx = ctx

ws_js.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,10 @@ func (w *writer) Close() error {
392392
// CloseRead implements *Conn.CloseRead for wasm.
393393
func (c *Conn) CloseRead(ctx context.Context) context.Context {
394394
c.closeReadMu.Lock()
395-
if c.closeReadCtx != nil {
395+
ctx2 := c.closeReadCtx
396+
if ctx2 != nil {
396397
c.closeReadMu.Unlock()
397-
return c.closeReadCtx
398+
return ctx2
398399
}
399400
ctx, cancel := context.WithCancel(ctx)
400401
c.closeReadCtx = ctx

0 commit comments

Comments
 (0)