From 277400660a563909b73941eda43c72eb192195c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 2 Sep 2021 12:49:13 +0200 Subject: [PATCH] fix: use a command timeout as fallback when user's render timeout is deactivated (render timeout === 0) --- config/environments/config.js | 1 + config/environments/development.js.example | 1 + config/environments/production.js.example | 1 + config/environments/staging.js.example | 1 + config/environments/test.js.example | 1 + lib/models/formats/ogr.js | 10 +++++++++- 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/environments/config.js b/config/environments/config.js index 11b4974e..705e2718 100644 --- a/config/environments/config.js +++ b/config/environments/config.js @@ -57,6 +57,7 @@ module.exports.db_pubuser_pass = 'public'; module.exports.db_host = process.env.CARTO_SQL_API_POSTGRES_HOST || 'localhost'; module.exports.db_port = process.env.CARTO_SQL_API_POSTGRES_PORT || '6432'; module.exports.db_batch_port = process.env.CARTO_SQL_API_POSTGRES_BATCH_PORT || '5432'; +module.exports.export_command_timeout = 5 * 60 * 1000; // 5 minutes in milliseconds module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.copy_timeout = "'5h'"; diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 584c1cae..e78d7aef 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -52,6 +52,7 @@ module.exports.db_pubuser_pass = 'public'; module.exports.db_host = 'localhost'; module.exports.db_port = '5432'; module.exports.db_batch_port = '5432'; +module.exports.export_command_timeout = 5 * 60 * 1000; // 5 minutes in milliseconds module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.copy_timeout = "'5h'"; diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 570e24c5..c4d0aa81 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -53,6 +53,7 @@ module.exports.db_pubuser_pass = 'public'; module.exports.db_host = 'localhost'; module.exports.db_port = '6432'; module.exports.db_batch_port = '5432'; +module.exports.export_command_timeout = 5 * 60 * 1000; // 5 minutes in milliseconds module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.copy_timeout = "'5h'"; diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index ba212f79..ec40a0c3 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -53,6 +53,7 @@ module.exports.db_pubuser_pass = 'public'; module.exports.db_host = 'localhost'; module.exports.db_port = '6432'; module.exports.db_batch_port = '5432'; +module.exports.export_command_timeout = 5 * 60 * 1000; // 5 minutes in milliseconds module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.copy_timeout = "'5h'"; diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 606c8e3e..b6150f32 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -50,6 +50,7 @@ module.exports.db_pubuser_pass = 'public'; module.exports.db_host = process.env.PGHOST || 'localhost'; module.exports.db_port = '5432'; module.exports.db_batch_port = '5432'; +module.exports.export_command_timeout = 5 * 60 * 1000; // 5 minutes in milliseconds module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 5 * 1000; // 5 seconds in milliseconds module.exports.copy_timeout = "'5h'"; diff --git a/lib/models/formats/ogr.js b/lib/models/formats/ogr.js index 78a2632f..085994ce 100644 --- a/lib/models/formats/ogr.js +++ b/lib/models/formats/ogr.js @@ -58,7 +58,15 @@ OgrFormat.prototype.toOGR = function (options, outFormat, outFilename, callback) var dbpass = dbopts.pass; var dbname = dbopts.dbname; - var timeout = options.timeout; + var timeout = 5 * 60 * 1000 // 5 minutes in milliseconds + + if (Number.isFinite(global.settings.export_command_timeout)) { + timeout = global.settings.export_command_timeout; + } + + if (Number.isFinite(options.timeout) && options.timeout > 0) { + timeout = options.timeout + } var that = this;