From 5978fdfcd52c638135bd22c2e4b71bb1acbe7947 Mon Sep 17 00:00:00 2001 From: Simon Grondin Date: Sat, 6 Jul 2019 13:44:47 -0500 Subject: [PATCH] Check for heartbeat before referencing it --- es5.js | 8 ++++---- lib/Bottleneck.js | 8 ++++---- light.js | 8 ++++---- src/Bottleneck.coffee | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/es5.js b/es5.js index 1d9a1a9..8f46de2 100644 --- a/es5.js +++ b/es5.js @@ -4359,13 +4359,13 @@ }.call(this); this._queues.on("leftzero", function () { - var base; - return typeof (base = _this._store.heartbeat).ref === "function" ? base.ref() : void 0; + var ref; + return (ref = _this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0; }); this._queues.on("zero", function () { - var base; - return typeof (base = _this._store.heartbeat).unref === "function" ? base.unref() : void 0; + var ref; + return (ref = _this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0; }); } diff --git a/lib/Bottleneck.js b/lib/Bottleneck.js index 87937a6..6f650d1 100644 --- a/lib/Bottleneck.js +++ b/lib/Bottleneck.js @@ -70,13 +70,13 @@ Bottleneck = function () { }.call(this); this._queues.on("leftzero", () => { - var base; - return typeof (base = this._store.heartbeat).ref === "function" ? base.ref() : void 0; + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0; }); this._queues.on("zero", () => { - var base; - return typeof (base = this._store.heartbeat).unref === "function" ? base.unref() : void 0; + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0; }); } diff --git a/light.js b/light.js index 46c2b98..ec17792 100644 --- a/light.js +++ b/light.js @@ -1080,12 +1080,12 @@ } }).call(this); this._queues.on("leftzero", () => { - var base; - return typeof (base = this._store.heartbeat).ref === "function" ? base.ref() : void 0; + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0; }); this._queues.on("zero", () => { - var base; - return typeof (base = this._store.heartbeat).unref === "function" ? base.unref() : void 0; + var ref; + return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0; }); } diff --git a/src/Bottleneck.coffee b/src/Bottleneck.coffee index 441533c..5c294c0 100644 --- a/src/Bottleneck.coffee +++ b/src/Bottleneck.coffee @@ -83,8 +83,8 @@ class Bottleneck else throw new Bottleneck::BottleneckError "Invalid datastore type: #{@datastore}" - @_queues.on "leftzero", => @_store.heartbeat.ref?() - @_queues.on "zero", => @_store.heartbeat.unref?() + @_queues.on "leftzero", => @_store.heartbeat?.ref?() + @_queues.on "zero", => @_store.heartbeat?.unref?() _validateOptions: (options, invalid) -> unless options? and typeof options == "object" and invalid.length == 0