From 2a62bcac2d453c7c882d663bb02b7a355057addc Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Mon, 20 Nov 2017 13:02:26 +0200 Subject: [PATCH] Correct accidental use of `Array.prototype.every` on an Object. Fixes the error reported in the 1.6.1 pull request. (Thanks, @yorrd!) It's worth nothing that the `DDP._allSubscriptionsReady` function which was broken is used by the deprecated `spiderable` package. Since `spiderable` is deprecated, it's advisable to look into ways to stop depending on it. Refs: https://github.com/meteor/meteor/pull/9274#issuecomment-345358178. --- packages/ddp-client/common/namespace.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/ddp-client/common/namespace.js b/packages/ddp-client/common/namespace.js index 5220fccf85..60e79c8543 100644 --- a/packages/ddp-client/common/namespace.js +++ b/packages/ddp-client/common/namespace.js @@ -1,8 +1,14 @@ import { DDPCommon } from 'meteor/ddp-common'; import { Meteor } from 'meteor/meteor'; +import { keys } from "meteor/ddp-common/utils.js"; import { Connection } from './livedata_connection.js'; +// This array allows the `_allSubscriptionsReady` method below, which +// is used by the `spiderable` package, to keep track of whether all +// data is ready. +const allConnections = []; + /** * @namespace DDP * @summary Namespace for DDP-related methods/classes. @@ -78,11 +84,10 @@ DDP.onReconnect = callback => { // Hack for `spiderable` package: a way to see if the page is done // loading all the data it needs. // -allConnections = []; DDP._allSubscriptionsReady = () => { return allConnections.every(conn => { - return conn._subscriptions.every(sub => { - return sub.ready; + return keys(conn._subscriptions).every(id => { + return conn._subscriptions[id].ready; }); }); };