From 87fd79f4b4a759c544900c6e9a4b90bf6aeedae0 Mon Sep 17 00:00:00 2001
From: Alejandro De Maria Antolinos <demariaa@esrf.fr>
Date: Tue, 11 Dec 2018 17:24:58 +0100
Subject: [PATCH] Added timeout

---
 app/controllers/events.controller.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/controllers/events.controller.js b/app/controllers/events.controller.js
index 8a9887a3..5df6ec91 100644
--- a/app/controllers/events.controller.js
+++ b/app/controllers/events.controller.js
@@ -11,6 +11,11 @@ const serverConfig = require('../../config/server.config.js');
 var moment = require('moment');
 var replaceall = require("replaceall");
 
+
+/** PDF generation response timeout */
+const TIMEOUT = 1000*60*10;
+
+
 /**
  * Replace the sessionId in every properties of the events. For each event, this includes the event content of all formats plus all other properties of the event
  * @param {array} events the events 
@@ -499,7 +504,7 @@ function getHTMLEventcontent(event) {
 
 exports.generatePDFByQuery = (req, res) => {
     logger.debug("Generating PDF");
-    req.setTimeout(1000*60*10);
+    req.setTimeout(TIMEOUT);
         
     logger.info("generatePDFByQuery", { investigationId: req.params.investigationId, find: req.body.find, sort: req.body.sort, limit: req.body.limit });
     var onSuccess = function (events) {
@@ -583,6 +588,7 @@ sendPDF = (html, req, sessionId, investigationId, response) => {
  * @param {*} res the http response
  */
 exports.generatePDFByInvestigation = (req, res) => {
+    req.setTimeout(TIMEOUT);
     let investigationId = req.params.investigationId;
 
 
-- 
GitLab