Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 0a389b4

Browse files
authored
Ensure subs is defined before calling filter (#16)
1 parent 4446c5a commit 0a389b4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/StreamrClient.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,18 @@ module.exports = class StreamrClient extends EventEmitter {
195195
this.handleError(`Error subscribing to ${response.stream}: ${response.error}`)
196196
} else {
197197
const subs = this.subsByStream[response.stream]
198+
199+
// The typeof array === 'object'
198200
if (subs && typeof subs === 'object') {
199201
delete subs.subscribing
202+
// Report subscribed to all non-resending Subscriptions for this stream
203+
subs.filter((sub) => !sub.resending)
204+
.forEach((sub) => {
205+
sub.setState(Subscription.State.subscribed)
206+
})
200207
}
201208

202209
debug('Client subscribed: %o', response)
203-
204-
// Report subscribed to all non-resending Subscriptions for this stream
205-
subs.filter((sub) => !sub.resending)
206-
.forEach((sub) => {
207-
sub.setState(Subscription.State.subscribed)
208-
})
209210
}
210211
})
211212

0 commit comments

Comments
 (0)