3

Some clients are failing to load the Google API in a production environment, but I'm not able to find anything wrong with my code.

Here's what I've got:

//  Load Google's JavaScript Client API using requireJS !async plugin.
//  You can learn more about the async plugin here: https://github.com/millermedeiros/requirejs-plugins/blob/master/src/async.js
define([
    'async!https://apis.google.com/js/client.js!onload'
], function () {
    'use strict';

    console.log("googleAPI has loaded", window.gapi, window.gapi.client);

    return window.gapi;
});

I've pulled this information from: Load async resource with requirejs timeout

The error message being displayed is:

Uncaught Error: Load timeout for modules: async!https://apis.google.com/js/client.js!onload_unnormalized2,async!https://apis.google.com/js/client.js!onload http://requirejs.org/docs/errors.html#timeout

This code doesn't produce any issues for me locally. It loads fine.

The first step I took to debug the issue was increasing the waitMinutes in requireConfig from 7 to 90. I thought maybe many people have very slow connections:

define(function () {

    require.config({

        baseUrl: 'js/',

        enforceDefine: true,

        //  I'm seeing load timeouts on in googleAPI -- seeing if increasing wait time helps.
        waitSeconds: 90,
        ...
    });
});

This did not seem to affect the issue. I still see many clients reporting an issue.

What other debugging options are available to me in this scenario? Thanks

1 Answer 1

0

So I ran into a similar issue when trying debug my application in Internet Explorer 8, and maybe my experience is similar to your clients'.

For me, I found that I was receiving a timeout error because my test browser was having issues retrieving resources through https due to outdated root certificates. I do all of my Internet Explorer testing in a VM running windows 7. When I was trying to load my application I received the same error you mentioned in your post:

Uncaught Error: Load timeout for modules:
async!https://apis.google.com/js/client.js!onload_unnormalized2,async!https://apis.google.com/js/client.js!onload http://requirejs.org/docs/errors.html#timeout

I tried the url manually and was brought to a 'Untrusted Certificate' warning page on my browser. This confused me, but as I later found out the root certificates on my windows os were outdated and causing a failure with the https handshake. The async plug-in seems to consume the authentication exceptions and just sits waiting for something to magically go through leading to the timeout error.

The solutions I found to work are as follows:

  1. Update the root certificates of the os
  2. Change the security properties of my browser to not require certificate authentication

As for suggestions for further debugging, I have two ideas:

  1. Try setting your browser's security properties as high as possible and see if you can recreate the issue (or just temporarily remove your local certificates)
  2. Ask your clients to set their browser's security properties as low as possible, making sure to disable certificate authentication requirements, and ask them if they are still having problems. (If their problems go away, they might need to manually update their local certificates)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.