4591: Avoid capturing critical exceptions in Websockets server.
authorBrett Smith <brett@curoverse.com>
Tue, 2 Dec 2014 14:59:55 +0000 (09:59 -0500)
committerBrett Smith <brett@curoverse.com>
Tue, 2 Dec 2014 21:28:43 +0000 (16:28 -0500)
commitd51224880c6524fd1b47543f3f312c3a000805c1
tree3c15509aa17b0af7cdf34dec1e30c1ceabd3ca14
parent0ecbb08536d02433272e62cf1878edd7927f66e1
4591: Avoid capturing critical exceptions in Websockets server.

Based on the current logs, the troubles we're currently hitting in
Websockets happen in push_events, where all the database work
happens.  These exceptions wrap PostgreSQL driver errors; they inherit
from StandardError, so they're being caught by the rescue block.
This commit re-raises those exceptions, which will cause the server to
crash (and presumably be restarted by a supervisor like runit).

We do sometimes see NoMemoryError, but the block to catch is in
ineffective because it usually manifests earlier in on_connect, when
the connection is first made.  In this case, Ruby's default exception
handling provides the behavior we want, so just remove the block.

In keeping with the theme of improved exception handling, I tightened
up the bad request detection.
services/api/lib/eventbus.rb