diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index 1d937374..5747be57 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -513,24 +513,27 @@ LayergroupController.prototype.getAffectedTables = function(user, dbName, layerg return queries.length ? queries.join(';') : null; }, - function findAffectedTables(err, sql) { + function getConnection(err, sql) { assert.ifError(err); if ( ! sql ) { throw new Error("this request doesn't need an X-Cache-Channel generated"); } - step( - function getConnection() { - self.pgConnection.getConnection(user, this); - }, - function getAffectedTables(err, connection) { - assert.ifError(err); + const next = this; - QueryTables.getAffectedTablesFromQuery(connection, sql, this); - }, - this - ); + self.pgConnection.getConnection(user, function (err, connection) { + if (err) { + return next(); + } + + next(null, connection, sql); + }); + }, + function getAffectedTables(err, connection, sql) { + assert.ifError(err); + + QueryTables.getAffectedTablesFromQuery(connection, sql, this); }, function buildCacheChannel(err, tables) { assert.ifError(err);