IOS app: method fails. Browser: working


#1

I’ve got to really strange situation with the same method with same parameters working in browser and debug-mode ios app and not working in production ios app.

We’ve got a login page in our app. Before login, we call meteor method ‘canLogin’ to check if it’s deactivated user and such. The same method, with the same byte-by-byte parameters, on the same server gives different results!

We call it like this:
Meteor.call('canLogin', username, function (err, res) {

Here are relevant WebSocket transcripts. From browser, login working:

a["{\"server_id\":\"0\"}"]
["{\"msg\":\"connect\",\"version\":\"1\",\"support\":[\"1\",\"pre2\",\"pre1\"]}"]
["{\"msg\":\"method\",\"method\":\"getServerTime\",\"params\":[],\"id\":\"1\"}"]
["{\"msg\":\"method\",\"method\":\"raix:push-setuser\",\"params\":[\"jv5guPw6xJn5F5bhN\"],\"id\":\"2\"}"]
["{\"msg\":\"method\",\"method\":\"raix:push-setuser\",\"params\":[\"jv5guPw6xJn5F5bhN\"],\"id\":\"3\"}"]
["{\"msg\":\"sub\",\"id\":\"mD2EgRm7z4QD6uemH\",\"name\":\"meteor.loginServiceConfiguration\",\"params\":[]}"]
["{\"msg\":\"sub\",\"id\":\"3FZQtpGvXhHaM6krQ\",\"name\":\"_roles\",\"params\":[]}"]
["{\"msg\":\"sub\",\"id\":\"9TmbXkEAHMFpbWHZa\",\"name\":\"meteor_autoupdate_clientVersions\",\"params\":[]}"]
a["{\"msg\":\"connected\",\"session\":\"8mTjEQ3WJzxoqkhSF\"}"]
a["{\"msg\":\"added\",\"collection\":\"kadira_settings\",\"id\":\"iwvFRfbcprEk8owb8\",\"fields\":{\"appId\":\"kDY8JdfzNYdDwnag9\",\"endpoint\":\"https://meteor-apm-engine.nodechef.com\",\"clientEngineSyncDelay\":10000,\"enableErrorTracking\":true}}"]
a["{\"msg\":\"updated\",\"methods\":[\"1\"]}"]
a["{\"msg\":\"result\",\"id\":\"1\",\"result\":1543486336145}"]
a["{\"msg\":\"updated\",\"methods\":[\"2\"]}"]
a["{\"msg\":\"result\",\"id\":\"2\",\"result\":false}"]
a["{\"msg\":\"updated\",\"methods\":[\"3\"]}"]
a["{\"msg\":\"result\",\"id\":\"3\",\"result\":false}"]
a["{\"msg\":\"ready\",\"subs\":[\"mD2EgRm7z4QD6uemH\"]}"]
a["{\"msg\":\"ready\",\"subs\":[\"3FZQtpGvXhHaM6krQ\"]}"]
["{\"msg\":\"method\",\"method\":\"canLogin\",\"params\":[\"kormanuser\"],\"id\":\"4\"}"]
a["{\"msg\":\"updated\",\"methods\":[\"4\"]}"]
a["{\"msg\":\"result\",\"id\":\"4\",\"result\":{\"canLogin\":true}}"]

from IOS app, not working:

a["{\"server_id\":\"0\"}"]
["{\"msg\":\"connect\",\"version\":\"1\",\"support\":[\"1\",\"pre2\",\"pre1\"]}"]
["{\"msg\":\"method\",\"method\":\"getServerTime\",\"params\":[],\"id\":\"1\"}"]
["{\"msg\":\"method\",\"method\":\"raix:push-setuser\",\"params\":[\"CmrSWxxG9ovXjZJuJ\"],\"id\":\"2\"}"]
["{\"msg\":\"method\",\"method\":\"raix:push-setuser\",\"params\":[\"CmrSWxxG9ovXjZJuJ\"],\"id\":\"3\"}"]
["{\"msg\":\"method\",\"method\":\"raix:push-update\",\"params\":[{\"id\":\"CmrSWxxG9ovXjZJuJ\",\"token\":{\"apn\":\"74b17348e067b831803b3d29d4b57685919fe82f11da820034d02a5d9281fe3e\"},\"appName\":\"main\",\"userId\":null,\"metadata\":{}}],\"id\":\"4\"}"]
["{\"msg\":\"sub\",\"id\":\"6QoW9x6vPY8L6x7ix\",\"name\":\"meteor.loginServiceConfiguration\",\"params\":[]}"]
["{\"msg\":\"sub\",\"id\":\"H3LMDRNpWbjfFnfhm\",\"name\":\"_roles\",\"params\":[]}"]
["{\"msg\":\"sub\",\"id\":\"sBTjnhd39XADu5XmS\",\"name\":\"meteor_autoupdate_clientVersions\",\"params\":[\"zivmvxxessdgg1xu8kc5\"]}"]
a["{\"msg\":\"connected\",\"session\":\"XtSzWPcGxBkvApeko\"}"]
a["{\"msg\":\"added\",\"collection\":\"kadira_settings\",\"id\":\"XGDnEbRL7qw9r6FMK\",\"fields\":{\"appId\":\"kDY8JdfzNYdDwnag9\",\"endpoint\":\"https://meteor-apm-engine.nodechef.com\",\"clientEngineSyncDelay\":10000,\"enableErrorTracking\":true}}"]
a["{\"msg\":\"updated\",\"methods\":[\"1\"]}"]
a["{\"msg\":\"result\",\"id\":\"1\",\"result\":1543477070703}"]
a["{\"msg\":\"updated\",\"methods\":[\"2\"]}"]
a["{\"msg\":\"result\",\"id\":\"2\",\"result\":true}"]
a["{\"msg\":\"updated\",\"methods\":[\"3\"]}"]
a["{\"msg\":\"result\",\"id\":\"3\",\"result\":true}"]
a["{\"msg\":\"updated\",\"methods\":[\"4\"]}"]
a["{\"msg\":\"result\",\"id\":\"4\",\"result\":{\"_id\":\"CmrSWxxG9ovXjZJuJ\",\"token\":{\"apn\":\"74b17348e067b831803b3d29d4b57685919fe82f11da820034d02a5d9281fe3e\"},\"appName\":\"main\",\"userId\":null,\"enabled\":true,\"createdAt\":{\"$date\":1543444607954},\"updatedAt\":{\"$date\":1543444616463}}}"]
["{\"msg\":\"method\",\"method\":\"canLogin\",\"params\":[\"kormanuser\"],\"id\":\"5\"}"]
a["{\"msg\":\"updated\",\"methods\":[\"5\"]}"]
a["{\"msg\":\"result\",\"id\":\"5\",\"result\":{\"canLogin\":false,\"reason\":\"User not found\"}}"]

The only differences are raix:push methods.

I’ve checked canLogin calls byte-to-byte, the only difference is the method number. 4 in browser, 5 in app.

The method in question is pretty simple:

        canLogin(username) {
            check(username, String)
            // check(password, String)
            const user = Meteor.users.findOne({ username })
            if (!user) {
                return {
                    canLogin: false,
                    reason: 'User not found'
                }
            }
            //...
        }

What can cause this really strange error?
One more clue: it’s failing only for new users (created recently).
Total users count is 3000+.
I’ll dig into db differences now but i really cannot understand how the method can work in one browser and don’t work in another (ios app).


#2

I was unable to reproduce the bug in other environment (sandbox server + production db + testflight app).

Some more information on environment:

  • apps are deployed via mup.js
  • there are few copies of prod app deployed to prod server, each having it’s own Mongo db in one Mongo container. Mongo docker image name is mongo:3.4.1.
  • strange thing – there are no logs in mongo container on prod. There are logs on stage.
  • stage uname: Linux ip-XXX 4.4.0-1022-aws #31-Ubuntu SMP Tue Jun 27 11:27:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • prod uname: Linux ip-XXX 3.13.0-87-generic #133-Ubuntu SMP Tue May 24 18:32:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

stage lsb:

$  lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

prod lsb:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.3 LTS
Release:	14.04
Codename:	trusty

#3

I think it’s some heisenbug connected with old environment versions. We will try to move prod to newer Ubuntu.


#4

We’ve moved to Ubuntu 18 and the bug is gone.