Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client is not safe for concurrent use #474

Open
dwrz opened this issue Jul 24, 2024 · 0 comments
Open

Client is not safe for concurrent use #474

dwrz opened this issue Jul 24, 2024 · 0 comments

Comments

@dwrz
Copy link

dwrz commented Jul 24, 2024

Using github.com/sendgrid/sendgrid-go v3.14.0, it appears that Client is not safe for concurrent use.

I was running a service with the race detector enabled, and it detected a data race at:

github.com/sendgrid/sendgrid-go.(*Client).SendWithContext() 
/vendor/github.com/sendgrid/sendgrid-go/base_interface.go:65 +0x8c

The problem is (at least) this line:

	cl.Body = mail.GetRequestBody(email)

If the client is called concurrently, there is a data race in writing the email parameter to the Body field.

Ideally, the assignment should either be protected by a mutex, or even better, the parameter should not be assigned to any field.

Otherwise, it would be great if you could document that the client is not safe for concurrent use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant