diff --git a/packages/@n8n/benchmark/scenarios/httpNode/httpNode.script.js b/packages/@n8n/benchmark/scenarios/httpNode/httpNode.script.js index dd0c85c07acca..b39198225966e 100644 --- a/packages/@n8n/benchmark/scenarios/httpNode/httpNode.script.js +++ b/packages/@n8n/benchmark/scenarios/httpNode/httpNode.script.js @@ -8,8 +8,17 @@ export default function () { check(res, { 'is status 200': (r) => r.status === 200, - 'http requests were OK': (r) => - // Response body is an array of the request status codes made with HttpNodes - JSON.parse(r.body).every((request) => request.statusCode === 200), + 'http requests were OK': (r) => { + if (r.status !== 200) return false; + + try { + // Response body is an array of the request status codes made with HttpNodes + const body = JSON.parse(r.body); + return Array.isArray(body) ? body.every((request) => request.statusCode === 200) : false; + } catch (error) { + console.error('Error parsing response body: ', error); + return false; + } + }, }); } diff --git a/packages/@n8n/benchmark/scenarios/jsCodeNodeOnceForEach/jsCodeNodeOnceForEach.script.js b/packages/@n8n/benchmark/scenarios/jsCodeNodeOnceForEach/jsCodeNodeOnceForEach.script.js index e53a35db8b7dd..11e8e87ac3df4 100644 --- a/packages/@n8n/benchmark/scenarios/jsCodeNodeOnceForEach/jsCodeNodeOnceForEach.script.js +++ b/packages/@n8n/benchmark/scenarios/jsCodeNodeOnceForEach/jsCodeNodeOnceForEach.script.js @@ -7,6 +7,16 @@ export default function () { const res = http.post(`${apiBaseUrl}/webhook/code-node-benchmark`, {}); check(res, { 'is status 200': (r) => r.status === 200, - 'has items in response': (r) => JSON.parse(r.body).length === 5, + 'has items in response': (r) => { + if (r.status !== 200) return false; + + try { + const body = JSON.parse(r.body); + return Array.isArray(body) ? body.length === 5 : false; + } catch (error) { + console.error('Error parsing response body: ', error); + return false; + } + }, }); }