Matrix message is lost when replying to message we haven't bridged yet
When testing, we noticed that this message failed to bridge across to Gitter. It's a message replying to someone else.
It looks like that message probably failed on modules/matrix-bridge/lib/matrix-event-handler.js#L163 which tries to find the message you're trying to reply to on the Gitter side. That makes sense from that event which does have a Matrix reply in it.
I'm assuming this from errors we are seeing like:
AssertionError [ERR_ASSERTION]: Expected `id` to look like an ObjectId but you passed id=undefined
at Object.findById (/opt/gitter/gitter-webapp/modules/chats/lib/chat-service.js:381:3)
at MatrixEventHandler.handleChatMessageCreateEvent (/opt/gitter/gitter-webapp/modules/matrix-bridge/lib/matrix-event-handler.js:163:45)
That probably means that the message they were referencing wasn't stored in our database yet. It could have been a race condition where one server is still processing or we haven't received that event yet before the reply comes through.
Solutions
We can fallback to sending the message to the room without the reply and maybe add a link point at the Matrix eventId it's trying to reference.
Dev notes
I see that it came through to the bridge and created the stat event modules/matrix-bridge/lib/matrix-event-handler.js#L127
$ ssh -L 5601:localhost:5601 deployer@logging-01.prod.gitter
// visit http://localhost:5601/
// search for "$Ap64yFCWfZsGyVsn2iCpNPKPvL2o34NiifvQBiLAObI
I don't see the event in the database though so it failed somewhere
$ ssh mongo-replica-01.prod.gitter
$ mongo gitter
> db.matricesbridgedchatmessage.findOne({ matrixEventId: '$Ap64yFCWfZsGyVsn2iCpNPKPvL2o34NiifvQBiLAObI' })