sandstorm-io/sandstorm — pull request #80 by dwrensha (2014-08-18 15:06:29+00:00)
Title: destroy WebSocket if sendBytes fails

There a few cases where it's possible for a WebSocket to be connected to a stale WebSession, including when:

1. another client has clicked on the "restart grain" button.
2. the grain's supervisor has crashed and restarted.

Currently, the socket is not destroyed in such cases, and the client can continue writing to it, with all data being silently dropped.

This patch destroys the socket when a write fails, thus propagating the error.

Once we have support for `reactToLostClient()`, I think we'll be able to destroy the socket even sooner.