Skip to content

Commit 16fd93e

Browse files
cursoragentClaude Sonnet 4.5
andcommitted
fix(grpc): Fix data race on stopMonitor field in stream wrapper
Initialize stopMonitor to a no-op function before calling context.AfterFunc to prevent a data race where the AfterFunc callback reads stopMonitor concurrently with the assignment if the context is already done. Co-Authored-By: Claude Sonnet 4.5 <claude-sonnet-4.5@cursor.sh>
1 parent 14ac33f commit 16fd93e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

grpc/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ func StreamClientInterceptor() grpc.StreamClientInterceptor {
113113
return nil, nilErr
114114
}
115115

116-
wrappedStream := &sentryClientStream{ClientStream: stream, span: span}
116+
wrappedStream := &sentryClientStream{
117+
ClientStream: stream,
118+
span: span,
119+
stopMonitor: func() bool { return false },
120+
}
117121
wrappedStream.stopMonitor = context.AfterFunc(ctx, func() {
118122
wrappedStream.finish(ctx.Err())
119123
})

0 commit comments

Comments
 (0)