From f3b7630c6f276545696d8abf91f90c03c3bb0cf6 Mon Sep 17 00:00:00 2001 From: Nik Nyby Date: Thu, 2 Apr 2015 21:08:03 -0400 Subject: Don't call callback if it's not a function --- .../web_labels/script_hash_worker.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/html_script_finder') diff --git a/lib/html_script_finder/web_labels/script_hash_worker.js b/lib/html_script_finder/web_labels/script_hash_worker.js index a8b2fdb..92ffb82 100644 --- a/lib/html_script_finder/web_labels/script_hash_worker.js +++ b/lib/html_script_finder/web_labels/script_hash_worker.js @@ -49,15 +49,28 @@ exports.addToCache = function (lic, delay, jsWebLabelsURL, callback) { lic.fileUrl ); console.debug('returning xhr from', lic.fileUrl); - callback(lic.fileUrl); + if (typeof callback === 'function') { + callback(lic.fileUrl); + } else { + console.debug('callback is not a function:', callback); + } } catch (e) { - callback(lic.fileUrl); + if (typeof callback === 'function') { + callback(lic.fileUrl); + } else { + console.debug('callback is not a function:', callback); + } } }; // just callback after 5 seconds if we don't get the answer yet. timers.setTimeout(function() { cb = function() {}; - callback(lic.fileUrl); }, 20000); + if (typeof callback === 'function') { + callback(lic.fileUrl); + } else { + console.debug('callback is not a function:', callback); + } + }, 20000); xhr({'url': lic.fileUrl}, cb); }, delay); -- cgit v1.2.3