Prevent buffering in the JS client from duplicating messages

- This fixes an issue where if a message was received while in the
  connecting state, it would be duplicated for each received handler.

#2595