tmc / grpc-websocket-proxy

A proxy to transparently upgrade grpc-gateway streaming endpoints to use websockets
MIT License
553 stars 72 forks source link

Monkey-patch for Golang bufio.Scanner hardcoded maxTokenSize = 64 KB #25

Closed vitalif closed 3 years ago

vitalif commented 3 years ago

Hi! There's a problem that affects etcd: grpc-websocket-proxy doesn't handle server messages (i.e replies!) longer 64 KB. Problem lies in Golang's bufio.Scanner that has a hard-coded maxTokenSize value equal to 64 KB. Error message in this case is: time="2020-10-18T15:42:56Z" level=warning msg="scanner err: bufio.Scanner: token too long" In this pull request I submit a rather ugly fix for this problem. It overwrites a private field inside the bufio.Scanner. I think it may be viable as a quick fix, but of course I'll appreciate if you'll fix it in some proper way. :-) A simple test example that reproduces the bug in etcd is here: https://gist.github.com/vitalif/a634ac0543e6cacdda4ec288d922d9cf

vitalif commented 3 years ago

Oops sorry, it seems the newest version already supports changing maximum buffer size, I only need to patch etcd itself