Random behaviour using the old js api library and the callback

197 views
Skip to first unread message

Xiao Lin Liu

unread,
Apr 22, 2020, 6:31:54 PM4/22/20
to Google Visualization API
Hi all,

in the last week, we have found that some of our client production environments is showing a random behavior which stops showing the maps

We do this call 


Most of time it works fine but some times, we get an 302 error and the process is stopped.

I know this is the old library version and we are changing to use the new library but I do concern about existing versions.  I've been reading in the group and in theory there is still backward compatibility.

Also, I'd like to remark that after a couple of days all started working perfectly but now it looks like this has come back but I do not get a 302 error and the behaviour is again random.

Is there something that is happening?

Regards,

Xiao 

Daniel LaLiberte

unread,
Apr 22, 2020, 7:16:20 PM4/22/20
to Google Visualization API
Hi Xiao,

We have been gradually ramping up the redirect from the old jsapi loader to the new loader, and it is supposed to support the callback parameter as well, but apparently not in the same way.

After ramping up to 100% a couple weeks ago, we discovered an internal problem, and reverted the redirect to 0%.  And a couple days ago, we started ramping up again.

Is your MapUtil.googleLoaderCallback the name of your own function, or one that you expect to be loaded.  Can you point me to your web page so that I can see what is happening?  I am curious what is happening and if we might be able to fix it, since there might be many more users out there who are seeing the same issue but silently.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/2f3b2dc4-9ca4-4fb8-8639-827da8db2ac2%40googlegroups.com.


--
Message has been deleted

Xiao Lin Liu

unread,
Apr 23, 2020, 1:31:27 PM4/23/20
to Google Visualization API

Also, this is part of the code:
We only wait for the callback and then get the credentials to log in and define our style. but the callback is never invoked in the failed case

public static loadApi(callback: () => void = null): void {
        if (MapUtil.loaded) {
            callback();
        } else {
            var script = <HTMLScriptElement>document.createElement("script");
            script.type = "text/javascript";
            document.getElementsByTagName("head")[0].appendChild(script);
            MapUtil.loadApiCallback = callback;
        }
    }
    public static googleLoaderCallback() {
        MapUtil.loaded = true;
        let credentials = window.sessionStorage.getItem("googleMapsApiCredentials");
        if (credentials === null || credentials === "") {
            KnockoutUtil.ajax({
                url: "/api/configurationapi/GetGoogleMapsAPICredentials",
                type: "GET",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: (data: string) => {
                    if (data !== null && data !== "") {

                        credentials = data;
                        window.sessionStorage.setItem("googleMapsApiCredentials", credentials);
                    }
                },
                error: () => {
                    throw new Error("Credentials could not be loaded")
                }
            })
        }
        let a: object;
            (<any>google).load("maps", "3", {
                "other_params": `client=${credentials}&sensor=false&channel=${client}&libraries=geometry,visualization,places,drawing `,
                "callback": () => {
                    MapUtil.impactMap = new google.maps.StyledMapType(MapUtil.MAP_IMPACT, { name: "Impact" });
                    MapUtil.loadApiCallback();
                    MapUtil.createPopupClass();
                }
            });
    }

Daniel LaLiberte

unread,
Apr 23, 2020, 4:21:24 PM4/23/20
to Google Visualization API
I see a potential cause of the problem. I don't quite follow your notation in the last part of the code (after let a: object), but I see:

"other_params": `client=${credentials}&sensor=false&channel=${client}&libraries=geometry,visualization,places,drawing `,

This would be a problem since the new loader is not yet handling the other_params parameter.  I am actually making a change to support it now, because it turns out this is the cause of some internal problems as well.

Also, this code makes me wonder:

            var script = <HTMLScriptElement>document.createElement("script");
            script.type = "text/javascript";
            document.getElementsByTagName("head")[0].appendChild(script);
            MapUtil.loadApiCallback = callback;

Since you add the script tag that includes the callback=MapUtil.googleLoaderCallback, but I don't see where you have defined MapUtil.googleLoaderCallback, unless it is the definition of public static googleLoaderCallback(), which would have to be static methods of MapUtil.  

But since there are multiple callbacks in your code, I am not sure which callback you are referring to. I see:

if (MapUtil.loaded) { callback(); }
jsapi?callback=MapUtil.googleLoaderCallback
MapUtil.loadApiCallback = callback;
google.load(... {"callback": () => {}})
MapUtil.loadApiCallback();

 And are you saying the callback is not called at all, or that it fails for some reason when it is called?




--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
Apr 23, 2020, 4:52:30 PM4/23/20
to Google Visualization API
Hi Daniel,

Yes, you are right this is only a piece of the entire class. The method for loadApiCallback is sort of the Maputil, actually all this code is part of the Maputil class.

When the call is routed to the new loader, the callback is not called at all. Also, why sometimes does it route to the new loader and some time it does not? Have you got the chance to see the screenshot about the network traces?

The other parameters fix, have you got an idea when it will be deployed? But I'm not sure if this is the cause of the problem as the callback is apparently not reached, when it is redirected to the new loader.

I can send you more info directly to your account due to some sensitivity data restrictions.

Regards

Xiao


Daniel LaLiberte

unread,
Apr 23, 2020, 5:11:44 PM4/23/20
to Google Visualization API
The redirects of jsapi to the new loader are now holding at a rate of 50%, meaning that half the requests are redirected, and half are not.  This is the maximally unstable rate which does 3 things:

1. raise attention about the transition
2. allow you to see both before and after, 
3. and in case 'after' is broken, allow users to see a working 'before' state at least part of the time.

We expect to add support for other_params early Monday morning.  And we will then push the redirect rate up to 100% on Wednesday.

If we see enough complaints about the absence of the other_params support, we could rollback the redirects to 0% again.  So far, this round, I only know about your issue.

Speaking of which, I am still not clear on the order of all those callbacks in your code.  Perhaps you could make a list of which calls you expect to happen when, or what alternative pathways might occur.  Feel free to email me directly instead of posting here.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
Apr 26, 2020, 6:51:13 PM4/26/20
to Google Visualization API
Hi Daniel,

I'm posting here the code to replicate the scenario with only 2 files, in case someone has spotted the same issue.
Did you have the chance to look at this and see if this will be solved by the fix deployed on Monday? Any idea, when it will be deployed on Monday?

the html page
<!DOCTYPE html>
<html>

<head>
  <title>Simple Map</title>
  <meta name="viewport" content="initial-scale=1.0">
  <meta charset="utf-8">
  <style>
    /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
    #map {
      height: 100%;
      width: 100%;
    }

    /* Optional: Makes the sample page fill the window. */
    html,
    body {
      height: 100%;
      margin: 0;
      padding: 0;
    }
  </style>
</head>

<body>
  <div style="display: flex;flex-direction: row;height: 100%;width: 100%;">
    <div id="map"></div>
  </div>
  <script src="mapUtil.js"></script>
  <script>
    function afterAll() {
      var uluru = {lat: -25.363, lng: 131.044};
                    this.newmap = new google.maps.Map(document.getElementById('map'), {
                        center: uluru,
                        zoom: 8
                      });
      console.log("Everything is loaded");
    }
    MapUtil.loadApi(afterAll);
  </script>
</body>

</html>

and the javascript file
var MapUtil = /** @class */ (function () {
    function MapUtil() {
    }
    MapUtil.loadApi = function (callback) {
        if (callback === void 0) { callback = null; }
        if (MapUtil.loaded) {
            callback();
        }
        else {
            var script = document.createElement("script");
            script.type = "text/javascript";
            document.getElementsByTagName("head")[0].appendChild(script);
            MapUtil.loadApiCallback = callback;
        }
    };
    MapUtil.googleLoaderCallback = function () {
        MapUtil.loaded = true;
        var credentials = "PUTCREDENTIALSHERE";
        var client = "PUTCLIENTHERE";
        var a;
        google.load("maps", "3", {
            "other_params": "client=" + credentials + "&sensor=false&channel=" + client + "&libraries=geometry,visualization,places,drawing ",
            "callback": function () {
                MapUtil.loadApiCallback();
            }
        });
    };
    MapUtil.loaded = false;
    return MapUtil;
}());

Running and refreshing this page, we can see that sometimes the callback is completed and something is never reached.

Again, thanks for your help on this issue and I do apologize for disturbing with this but this issue is being critical on our product and we need to check all the options and how to solve it asap.

Regards

Xiao

Daniel LaLiberte

unread,
Apr 27, 2020, 10:43:02 AM4/27/20
to Google Visualization API
I've implemented the other_params setting when loading the 'maps' module.  So I would expect your use of other_params will be processed correctly, whereas it has been ignored so far (in the new loader).

I will be updating the loader very soon, for the update of Google Charts so that 'upcoming' will be version '48'.  This update will also support the other_params setting for 'maps', though not for any other modules (at this time).

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
Apr 27, 2020, 11:49:30 AM4/27/20
to Google Visualization API
Thanks for the update, just let me know when it's update so I can test it on my side.

However, I'm concerned that the other_params is the actual root of our problem as in our case the callback is never trigger and the other_params is used just on the callback.

I don't think there is any other public endpoint with the new version which I can have a look in the meantime.

Regards,

Xiao 

Daniel LaLiberte

unread,
Apr 27, 2020, 12:06:30 PM4/27/20
to Google Visualization API
I just pushed out the new loader (for the v48 update) which supports the other_params.   Let me know if there are any issues.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
Apr 27, 2020, 12:47:08 PM4/27/20
to google-visua...@googlegroups.com
I've just tested it and  it's still failing. When the redirect happens, the callback does not happen.

image.png
Does the rerouting works with callback  to internal methods?

Any further idea? is Wednesday the final rolled out date?


Daniel LaLiberte

unread,
Apr 27, 2020, 1:06:31 PM4/27/20
to Google Visualization API
The callback might be problematic if you are referencing it with a string name of the local function.   We are not doing an eval of the function, but looking it up as a global symbol. But if you can reference your callback function as a global string or as a function object, that ought to work.    I see you are passing a function object, so that ought to work.

Make sure you are not using a cached copy of the previous version of the loader.   I changed the caching headers for the loader over an hour ago, but sometimes browsers or caching servers will hold on to old versions longer than they should. 

Xiao Lin Liu

unread,
Apr 27, 2020, 1:31:16 PM4/27/20
to google-visua...@googlegroups.com
I did refresh all and it is failing. I'll try again later.

Regarding the 100% rolled out date, is it still on Wednesday?. As I said, we are working on a fix on our side  but I want to know how much time we have to apply the fix to our clients.

Regards

Xiao  

Xiao Lin Liu

unread,
Apr 27, 2020, 1:41:35 PM4/27/20
to Google Visualization API
Also, I don't think you can defer the deployment because there is only one person with issues, can't you?

Daniel LaLiberte

unread,
Apr 27, 2020, 1:43:07 PM4/27/20
to Google Visualization API
The redirect of jsapi to the new loader is still planned to be 100% on Wednesday, yes.  I will be adding some tests of the callback to make sure it is doing what I believe it should be doing.

Daniel LaLiberte

unread,
Apr 27, 2020, 1:45:46 PM4/27/20
to Google Visualization API
It is possible to defer, but we haven't heard of any other problems this time around, so you might be close to the last person with issues.

On Mon, Apr 27, 2020 at 1:41 PM Xiao Lin Liu <xiaol...@gmail.com> wrote:
Also, I don't think you can defer the deployment because there is only one person with issues, can't you?

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
Apr 27, 2020, 2:01:00 PM4/27/20
to Google Visualization API
If you can check with the test code I did send you and let me know if you can spot the problem, that will be really helpful.

Again thanks for your invaluable help.

Xiao

Xiao Lin Liu

unread,
Apr 27, 2020, 2:10:07 PM4/27/20
to Google Visualization API
Just a naive question, Will it be possible to defer this a couple of days when it's only one company with problems.

I had escalate the problem to the Google maps support before reaching to this forum and unfortunately, I'm indirectly making you providing such support( I do apologize for that) as I could not get the root of the problem, now I'm much closer!

Wolf Bergenheim

unread,
Apr 27, 2020, 2:38:06 PM4/27/20
to Google Visualization API
Hello,

Yes, it might be possible to defer a little. How much time would you need? Would 1 week be meaningful for you?

Best Regards,
Wolf Bergenheim
Google Maps Support

Xiao Lin Liu

unread,
Apr 27, 2020, 5:46:03 PM4/27/20
to google-visua...@googlegroups.com
Hi Wolf,

if  this can be scheduled it will be great, this will give us time enough to promote our changes to the clients.

When will best suits you? Next Monday, Tuesday?

if you need the case number I raised with the support team, let me know and I'll be more than happy to provide it.

Regards,

Xiao 



--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
Message has been deleted

Xiao Lin Liu

unread,
Apr 28, 2020, 12:43:31 PM4/28/20
to google-visua...@googlegroups.com
Hi Wolf,

Monday is perfect for us so far. We are going to start sending the patches  to the client tomorrow and unless something changes, we should be ok to do that by Monday.

Anyway, I can provide an update on Friday.

For the case number
- 2303283: this was the original one
- 23225216: this was the one we escalate, in case we could contact directly to any support from this team.

Thanks again for all the help

Regards

Xiao 

El mar., 28 abr. 2020 a las 1:19, 'Wolf Bergenheim' via Google Visualization API (<google-visua...@googlegroups.com>) escribió:
Hi Xiao,

Please do share the case number, I can then look it up. And yes Monday Next week, if that will be sufficient time for you.
Let's check in on Friday what your status is, and preliminarily set the launch to Monday (morning) next week.

Daniel LaLiberte

unread,
Apr 28, 2020, 12:53:46 PM4/28/20
to Google Visualization API
By the way, I did do some additional tests of both the jsapi?callback=func and google.load(... {callback: func}, and both work for me.   You can also use google.setOnLoadCallback when loading 'maps'.   There is a possibility that combining the jsapi callback with the other mechanisms in the same document will cause some confusion, and this turns out to be difficult for me to test as well.  

It is possible that as soon as you use google.load or google.setOnLoadCallback, it will forget about the jsapi?callback=func.    But it shouldn't be necessary to use both at the same time, since either one should be able to do what you need.   So I would recommend trying to get rid of one or the other.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
May 1, 2020, 1:15:46 PM5/1/20
to Google Visualization API
Hi, just let you know that we are ok for Monday deployment. Clients have taken our patch and Monday is perfect.

Again, thanks for all your help and flexibility.

Regards

Xiao

Wolf Bergenheim

unread,
May 4, 2020, 4:30:20 AM5/4/20
to google-visua...@googlegroups.com
Thank you for the update! Glad to hear it all worked out!

br,
Wolf Bergenheim
Google Maps Support
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Xiao Lin Liu

unread,
May 4, 2020, 7:15:28 AM5/4/20
to Google Visualization API
Hi Wolf,

Once the roll out is completed today, Would you mind to let me know? Some clients wanted to know when the process is done.

A quick note in this thread, should be enough.

Regards

Xiao 



Wolf Bergenheim

unread,
May 4, 2020, 7:44:52 PM5/4/20
to google-visua...@googlegroups.com
Hi Xiao,

We have now fully rolled out the replacement. All requests are now hitting the new google visualization loader.

Best Regards,
Wolf Bergenheim
Google Maps Support
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages