Skip to content

Better log out the requests that matrix-appservice-bridge/matrix-bot-sdk throws out as errors

Better log out the requests that matrix-appservice-bridge/matrix-bot-sdk throws out as errors.

We're only worrying about improving because that's where we drill down and investigate from more easily than the giant output from an import worker.

Follow-up to !2313 (merged)

Part of #2609 (closed)

Before in scripts/utils/gitter-to-matrix-historical-import-one-room.js

Before in scripts/utils/gitter-to-matrix-historical-import-one-room.js (yes, it doesn't print the error because it doesn't have an err.stack like errors should):

2023-01-18T09:30:06.468Z - error: Error occurred while backfilling events for opts.uri=undefined gitterRoomId=xxx:

Before in scripts/utils/gitter-to-matrix-historical-import-worker.js

Before in scripts/utils/gitter-to-matrix-historical-import-worker.js it printed a garbled mess with no indication which request or URL failed.

2023-01-17T20:26:19.683Z - error: concurrentQueue: Failed to process itemId=xxx_eventsCount=4, httpVersionMajor=1, httpVersionMinor=1, httpVersion=1.1, complete=true, rawHeaders=Date,Tue, 17 Jan 2023 20:26:19 GMT,Content-Type,application/json,Transfer-Encoding,chunked,Connection,close,Cache-Control,no-cache, no-store, must-revalidate,Access-Control-Allow-Origin,*,Access-Control-Allow-Methods,GET, HEAD, POST, PUT, DELETE, OPTIONS,Access-Control-Allow-Headers,X-Requested-With, Content-Type, Authorization, Date,Strict-Transport-Security,max-age=15724800; includeSubDomains, rawTrailers=, aborted=false, upgrade=false, url=, method=null, statusCode=400, statusMessage=Bad Request, _consuming=true, _dumped=false, toJSON=function responseToJSON () {
  var self = this
  return {
    statusCode: self.statusCode,
    body: self.body,
    headers: self.headers,
    request: requestToJSON.call(self.request)
  }
}

After in scripts/utils/gitter-to-matrix-historical-import-one-room.js

Now we actually get the request URL and details of the response:

2023-01-18T09:44:24.581Z - error: Error occurred while backfilling events for opts.uri=undefined gitterRoomId=xxx: matrix-appservice-bridge/matrix-bot-sdk threw an error that looked more like a request object, see {"statusCode":400,"body":{"errcode":"M_ROOM_IN_USE","error":"Room alias already taken"},"headers":{"date":"Wed, 18 Jan 2023 09:44:24 GMT","content-type":"application/json","transfer-encoding":"chunked","connection":"close","cache-control":"no-cache, no-store, must-revalidate","access-control-allow-origin":"*","access-control-allow-methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"X-Requested-With, Content-Type, Authorization, Date","strict-transport-security":"max-age=15724800; includeSubDomains"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"gitter.ems.host","port":443,"hostname":"gitter.ems.host","hash":null,"search":null,"query":null,"pathname":"/_matrix/client/r0/createRoom","path":"/_matrix/client/r0/createRoom","href":"https://gitter.ems.host/_matrix/client/r0/createRoom"},"method":"POST","headers":{"Authorization":"<redacted>","Content-Type":"application/json","content-length":127}}}
2023-01-18T09:44:24.583Z - warn: Waiting for this ongoing message send request to finish and bridged information stored...
redis handler failed during shutdown: TypeError: Cannot read property 'activeMasterClient' of undefined
Edited by Eric Eastwood

Merge request reports