Closed prestonvanloon closed 4 years ago
If you send multiple requests quickly, they overwrite the options with the receiver.
Expected: Send three requests to send message with a receiver field different phone numbers. Messages are sent to three different numbers.
Observed behavior: the message is sent three times to same number.
Here is the offending code where the request shares / reuses the same options by copying the pointer to the options. https://github.com/Swatto/promtotwilio/blob/d63336cf34797f5634f7c72b1284a4af9a97d23e/options_with_handler.go#L54
The service needs a mutex around this option or make a deep copy of the options before mutating it.
Here's the simplest way to understand the problem: https://play.golang.org/p/rZyz-ivCnch
And here's a simple fix to that example: https://play.golang.org/p/_NLLKtaP0mv
If you send multiple requests quickly, they overwrite the options with the receiver.
Expected: Send three requests to send message with a receiver field different phone numbers. Messages are sent to three different numbers.
Observed behavior: the message is sent three times to same number.
Here is the offending code where the request shares / reuses the same options by copying the pointer to the options. https://github.com/Swatto/promtotwilio/blob/d63336cf34797f5634f7c72b1284a4af9a97d23e/options_with_handler.go#L54
The service needs a mutex around this option or make a deep copy of the options before mutating it.