Skip to content

Client is not safe for concurrent use #474

Open
@dwrz

Description

@dwrz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions