Search code examples
javascriptgoogle-apigoogle-api-js-clientgoogle-api-javascript-client

Google Platform.js suddenly throwing _.Rp undefined exception decipte no change in code


From 19 July 23.45 GTM +1 all our applications using platform.js (live and in testing) started throwing exceptions on loading gapi features found in platform.js. No code change has been made, and the error started happening everywhere at once.

app.js:178 Uncaught TypeError: Cannot read property 'init' of undefined (referring to gapi.auth.init)

uncaught TypeError: _.Rp is not a function

Both errors originate from platform.js

I've attempted to rebuild the fronted js project with no luck, have also tried adding <script src="https://apis.google.com/js/client.js"></script> before loading platform.js, but to no avail.

It is now 1.30 AM, thanks in advance, from a very tired developer.

Following is a screenshot of the errors

loadGoogleApi: function (callback, context) {
    var self = this;
    if (typeof gapi == 'undefined') {
        callback.apply(context || self);
        return;
    }
    return gapi.load('auth2', function() {
        self.auth2 = gapi.auth2.init({
            scope: 'profile email',
            client_id: Core.googleClientId
        });
        self.auth2.currentUser.listen(function (user) {
            debug.log('Google user', user);
            app.googleUser = user;
        });
        callback.apply(context || self);
    });

Solution

  • Actually we found the issue. It was a conflict we another JS script we are using. In this custom JS, we created a function called Map() and it seems that google has updated its library last night and now is also using a function called Map. We just rename our custom JS function, and it is working.