Hello, I've got a websocket implementation in a gem, and occasionally on a write I'm seeing a IndexError: negative length -1?

It seems that the nwrote variable in this method is set to -1 somehow and it's bubbling up as an array error.
I'm on Ruby 2.7.2 and OpenSSL library version 2.1.2 (not quite sure how that version number works as that nwrote var was introduced in 2.2.0 🤷♀️)