Closed ioworker0 closed 3 years ago
From what I understand, WriteFrame
isn't designed to be concurrent safe and it's documentation says nothing about thread safety. Isn't this an expected behaviour?
From what I understand,
WriteFrame
isn't designed to be concurrent safe and it's documentation says nothing about thread safety. Isn't this an expected behaviour?
Thank you for your immediate response!
I just hope this helps someone else and I didn't know it is thread-unsafe.
There was a bug that stuck us for a few days. The error message shows as follows:
This bug is hard to find through testing alone, because it is triggered by low-probability events.
But, let's take a closer look at the code below:
https://github.com/gobwas/ws/blob/2effe5ec7e4fd737085eb56beded3ad6491269dc/write.go#L90-L97
So, it's necessary that we write every frame in a concurrency-safe way.
P.S. we figured it out with a lock.