zenhack / go-websocket-capnp

Apache License 2.0
3 stars 2 forks source link

js: avoid blocking the event loop #4

Closed zenhack closed 1 year ago

zenhack commented 1 year ago

...by using spsc, an unbounded queue, instead of a channel for messages.

This makes use of spsc's .Close() method, introduced in https://github.com/capnproto/go-capnproto2/pull/449


In principle, without this you could deadlock the event loop by creating a websocket connection and then never actually calling .Decode(), though this is unlikely in normal use.

zenhack commented 1 year ago

Can't merge this until the corresponding go-capnp pr is merged, so parking it here for now.