From 2de628adacf113f78474ad2f525ca902ea09fc0d Mon Sep 17 00:00:00 2001 From: Scott Bell Date: Wed, 9 Oct 2024 12:16:02 +0200 Subject: [PATCH] ensure we have a reference value before we slice --- src/plugins/comps/CompsMathWorker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/comps/CompsMathWorker.js b/src/plugins/comps/CompsMathWorker.js index 4831c606a6..00de8bdd1e 100644 --- a/src/plugins/comps/CompsMathWorker.js +++ b/src/plugins/comps/CompsMathWorker.js @@ -13,6 +13,7 @@ onconnect = function (e) { try { if (type === 'calculateRequest') { responseType = 'calculationRequestResult'; + console.debug(`📫 Received new calculation request with callback ID ${callbackID}`); result = calculateRequest(telemetryForComps, parameters, expression); } else if (type === 'calculateSubscription') { responseType = 'calculationSubscriptionResult'; @@ -86,7 +87,7 @@ function calculate(dataFrame, parameters, expression) { if (referenceParameter.sampleSize && referenceParameter.sampleSize > 0) { // enforce sample size by ensuring referenceValue has the latest n elements // if we don't have at least the sample size, skip this iteration - if (referenceValue.length < referenceParameter.sampleSize) { + if (!referenceValue.length || referenceValue.length < referenceParameter.sampleSize) { return; } referenceValue = referenceValue.slice(-referenceParameter.sampleSize);