message: Do not retry leave after 10 attempts
diff: @@ -27,6 +27,7 @@ const NICK_USERID_CACHE_MAX = 512;
  const LEAVE_CONCURRENCY = 10;
  const LEAVE_DELAY_MS = 3000;
  const LEAVE_DELAY_JITTER = 5000;
  +const LEAVE_MAX_ATTEMPTS = 10;
  function IrcHandler(ircBridge, config) {
  config = config || {}
  @@ -759,8 +760,7 @@ IrcHandler.prototype.onKick = Promise.coroutine(function*(req, server,
  * @param {IrcServer} server : The sending IRC server.
  * @param {IrcUser} leavingUser : The user who parted.
  * @param {string} chan : The channel that was left.
  - * @param {string} kind : The kind of part (e.g. PART, KICK, BAN, quit
  - * netsplit, etc)
  + * @param {string} kind : The kind of part (e.g. PART, KICK, BAN, QUIT, netsplit, etc)
  * @return {Promise} which is resolved/rejected when the request finishes.
  */
  IrcHandler.prototype.onPart = Promise.coroutine(function*(req, server, leavingUser, chan, kind) {
  @@ -819,7 +819,6 @@ IrcHandler.prototype.onPart = Promise.coroutine(function*(req, server, leavingUs
  const promise = this._leaveQueue.enqueue(chan+leavingUser.nick, {
  id: chan+leavingUser.nick,
  - attempts: 0,
  rooms: matrixRooms,
  userId: typeof(matrixUser) === "string" ? matrixUser : matrixUser.getId(),
  shouldKick: leavingUser.isVirtual, // kick if they are not ours
  @@ -1133,12 +1132,11 @@ IrcHandler.prototype._invalidateNickUserIdMap = function(server, channel) {
  IrcHandler.prototype._handleLeaveQueue = async function(item) {
  const bridge = this.ircBridge.getAppServiceBridge();
  let retryRooms = [];
  + item.attempts = item.attempts || 0;
  for (const room of item.rooms) {
  const roomId = room.getId();
  item.req.log.info(
  - "Leaving room %s (%s)",
  - roomId,
  - item.userId
  + `Leaving room ${roomId} (${item.userId}) (attempt: ${item.req.attempts})`,
  );
  try {
  if (item.shouldKick) {
  @@ -1168,6 +1166,10 @@ IrcHandler.prototype._handleLeaveQueue = async function(item) {
  }
  await Promise.delay(LEAVE_DELAY_MS + (Math.random() * LEAVE_DELAY_JITTER));
  item.attempts++;
  + if (item.attempts === LEAVE_MAX_ATTEMPTS) {
  + item.req.log.error("Couldn't leave: Hit attempt limit");
  + return;
  + }
  this._leaveQueue.enqueue(item.id + item.attempts, {
  ...item,
  rooms: retryRooms,
  