Logs with console.error too large row erros
This commit is contained in:
parent
296bb658bf
commit
45f5b398a0
@ -33,6 +33,13 @@ PostgresFormat.prototype.handleQueryRowWithSkipFields = function(row, result) {
|
||||
this.handleQueryRow(row, result);
|
||||
};
|
||||
|
||||
PostgresFormat.prototype.handleQueryError = function(err) {
|
||||
this.error = err;
|
||||
if (err.message && err.message.match(/row too large, was \d* bytes/i)) {
|
||||
console.error(JSON.stringify({error: err.message}));
|
||||
}
|
||||
};
|
||||
|
||||
PostgresFormat.prototype.handleNotice = function(msg, result) {
|
||||
if ( ! result.notices ) result.notices = [];
|
||||
for (var i=0; i<msg.length; i++) {
|
||||
@ -125,7 +132,7 @@ PostgresFormat.prototype.sendResponse = function(opts, callback) {
|
||||
query.on('row', that.handleQueryRow.bind(that));
|
||||
}
|
||||
query.on('end', that.handleQueryEnd.bind(that));
|
||||
query.on('error', function(err) { that.error = err; });
|
||||
query.on('error', that.handleQueryError.bind(that));
|
||||
query.on('notice', function(msg) {
|
||||
that.handleNotice(msg, query._result);
|
||||
});
|
||||
|
@ -1464,4 +1464,43 @@ test('GET with callback must return 200 status error even if it is an error', fu
|
||||
);
|
||||
});
|
||||
|
||||
test('too large rows get into error log', function(done){
|
||||
|
||||
var dbMaxRowSize = global.settings.db_max_row_size;
|
||||
global.settings.db_max_row_size = 4;
|
||||
|
||||
var consoleErrorFn = console.error;
|
||||
var hit = false;
|
||||
var consoleError;
|
||||
console.error = function(what) {
|
||||
hit = true;
|
||||
consoleError = what;
|
||||
};
|
||||
assert.response(
|
||||
app,
|
||||
{
|
||||
url: "/api/v1/sql?" + querystring.stringify({
|
||||
q: "SELECT * FROM untitle_table_4"
|
||||
}),
|
||||
headers: {
|
||||
host: 'vizzuality.cartodb.com'
|
||||
},
|
||||
method: 'GET'
|
||||
},
|
||||
{
|
||||
status: 400
|
||||
},
|
||||
function() {
|
||||
assert.equal(hit, true);
|
||||
assert.ok(JSON.parse(consoleError).error.match(/^row too large.*/i), "Expecting row size limit error");
|
||||
|
||||
global.settings.db_max_row_size = dbMaxRowSize;
|
||||
console.error = consoleErrorFn;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user