From 06385eb3bff7f2f90294e8f4ee4077e8bf8fb10d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Sep 2021 22:55:48 +0200 Subject: [PATCH] Bug Fix, Platform Client Crash --- Platform/Client/httpInterface.js | 22 +++++++++++++++++++ .../Foundations/SA/Utilities/HttpRequests.js | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 8c6e16536..a064df2cc 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -47,6 +47,7 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } let params = JSON.parse(body) switch (params.method) { @@ -135,6 +136,7 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } let params = JSON.parse(body) switch (params.method) { @@ -245,6 +247,8 @@ exports.newHttpInterface = function newHttpInterface() { SA.projects.foundations.utilities.httpRequests.getRequestBody(httpRequest, httpResponse, processRequest) function processRequest(messageReceived) { + if (messageReceived === undefined) { return } + let timestamp = (new Date()).valueOf() let source = requestPath[3] let exchange = requestPath[4] @@ -295,6 +299,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Nodes' @@ -326,6 +332,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Concepts' @@ -357,6 +365,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Topics' @@ -388,6 +398,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Tutorials' @@ -419,6 +431,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Reviews' @@ -450,6 +464,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let docsSchema = JSON.parse(body) let project = requestPath[3] let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Books' @@ -995,6 +1011,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let params = JSON.parse(body) switch (params.method) { @@ -1416,6 +1434,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { try { + if (body === undefined) { return } + let plugin = JSON.parse(body) let project = requestPath[2] let folder = requestPath[3] @@ -1550,6 +1570,8 @@ exports.newHttpInterface = function newHttpInterface() { async function processRequest(body) { + if (body === undefined) { return } + let fileContent = body let fileName = unescape(requestPath[2]) let filePath = global.env.PATH_TO_MY_WORKSPACES + '/' + fileName + '.json' diff --git a/Projects/Foundations/SA/Utilities/HttpRequests.js b/Projects/Foundations/SA/Utilities/HttpRequests.js index 2dc945b1b..7c442b3bc 100644 --- a/Projects/Foundations/SA/Utilities/HttpRequests.js +++ b/Projects/Foundations/SA/Utilities/HttpRequests.js @@ -26,12 +26,12 @@ exports.newFoundationsUtilitiesHttpRequests = function () { httpRequest.on('error', function (err) { console.log('[ERROR] getBody -> err.stack = ' + err.stack) SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) - throw('Not possible to get HTTP Body.') + callback() }) } catch (err) { console.log('[ERROR] getBody -> err.stack = ' + err.stack) SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) - throw('Not possible to get HTTP Body.') + callback() } } } \ No newline at end of file