message: Add joinRetry delay
diff: @@ -12,6 +12,9 @@ var MatrixAction = require("../models/MatrixAction");
  var Queue = require("../util/Queue.js");
  var QuitDebouncer = require("./QuitDebouncer.js");
  +const MAX_JOIN_ATTEMPTS = 1000;
  +const JOIN_DELAY_MS = 250;
  +
  function IrcHandler(ircBridge) {
  this.ircBridge = ircBridge;
  // maintain a map of which user ID is in which PM room, so we know if we
  @@ -535,15 +538,18 @@ IrcHandler.prototype.onJoin = Promise.coroutine(function*(req, server, joiningUs
  const joinRetry = (attempts) => {
  req.log.debug(`Joining room (attempts:${attempts})`);
  return intent.join(room.getId()).catch((err) => {
  - if (err.httpStatus === undefined || err.httpStatus <= 500) {
  + if (attempts > MAX_JOIN_ATTEMPTS || err.httpStatus === undefined || err.httpStatus <= 500) {
  req.log.error(`Not retrying join for ${room.getId()}.`);
  return Promise.reject(err);
  }
  attempts++;
  - req.log.warn(`Failed to join ${room.getId()} (attempts:${attempts}) - ${err}.`);
  + const delay = JOIN_DELAY_MS*attempts;
  + req.log.warn(`Failed to join ${room.getId()} attempts:${attempts} ${err}.delaying for ${delay}ms`);
  req.log.debug(`Failed with: ${err.errcode} ${err.message}`);
  + return Promise.delay(delay).then(() => {
  return joinRetry(attempts);
  });
  + });
  };
  return Promise.all([
  joinRetry(0),
  