Before a user has linked a stream id to their user account, the result of looking up a user for that stream will be null. The code was expecting there to always be a user for the stream. This meant that when an event was sent to the realtime api, the event emitter caused the user to be looked up. The result was null, which meant looking up encodedusername caused the app to fall over. This prevents the event from being written to the database as the app has gone down before having a chance to make the call to 1self. I added a check for null which fixes this.