From 686cc4ab9512d8033fdff277f4ad3613dc27c8b6 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Thu, 14 Apr 2016 17:24:04 +0300 Subject: [PATCH] Checking if object has defined key for Pointer constraints in liveQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removing sessionToken and authData from _User objects included in a query This bug caused sessionToken to be replaced on client side to some old sessionToken from DB. * Removing dangling variable that is never used * Checking if object has defined key for Pointer constraints in liveQuery If there is a liveQuery subscription, with Pointer type constrains (e.g query.equalTo('user', Parse.User.current())), and new object has undefined value for that field, we get this error: error: Uncaught internal server error. [TypeError: Cannot read property 'className' of undefined] TypeError: Cannot read property 'className' of undefined at matchesKeyConstraints (…/node_modules/parse-server/lib/LiveQuery/QueryTools.js:145:51) --- src/LiveQuery/QueryTools.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index 8a47f25c..605e49b1 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -141,6 +141,7 @@ function matchesKeyConstraints(object, key, constraints) { if (constraints.__type) { if (constraints.__type === 'Pointer') { return ( + typeof object[key] !== 'undefined' && constraints.className === object[key].className && constraints.objectId === object[key].objectId );