From 40e72157de3c45cf11631274a4fcfaf0e0aa4f78 Mon Sep 17 00:00:00 2001 From: Aapeli Date: Fri, 1 Jun 2018 12:31:53 +0200 Subject: [PATCH] Ensure subs is defined before calling filter --- src/StreamrClient.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/StreamrClient.js b/src/StreamrClient.js index fd33ac951..fa536c556 100644 --- a/src/StreamrClient.js +++ b/src/StreamrClient.js @@ -195,17 +195,18 @@ module.exports = class StreamrClient extends EventEmitter { this.handleError(`Error subscribing to ${response.stream}: ${response.error}`) } else { const subs = this.subsByStream[response.stream] + + // The typeof array === 'object' if (subs && typeof subs === 'object') { delete subs.subscribing + // Report subscribed to all non-resending Subscriptions for this stream + subs.filter((sub) => !sub.resending) + .forEach((sub) => { + sub.setState(Subscription.State.subscribed) + }) } debug('Client subscribed: %o', response) - - // Report subscribed to all non-resending Subscriptions for this stream - subs.filter((sub) => !sub.resending) - .forEach((sub) => { - sub.setState(Subscription.State.subscribed) - }) } })