Hi James, The change to the loader was made on June 13, so it is plausible your clients didn't notice the problem until the 17th. The changes involved adding support to handle redirects from the old jsapi loader, which may die at any moment before we have time to handle the redirects more gracefully. So the new loader now exports 'google.load' if it is not already defined, and handles calls of google.load() and google.setOnLoadCallback(). If the jsapi loader is being used along with the new loader, that might cause some confusion, but I believe it would only be a problem if you are calling google.load().
It appears that you are loading the 'maps' api directly, and not via the old jsapi loader, which is good. Hmm, that makes me wonder if we might still have a problem once we are redirecting jsapi, in the situation that you load both jsapi and the new loader. Users of some of the older versions of the map-related charts were forced to load jsapi (to also load 'maps', so we could use its geocoding service) and the new loader. Anyway, this is something to check on, but probably not relevant for you. If you have never seen the problem occur from your network, I would be inclined to guess this is related to the local configuration of the network or possibly caching servers, though I can't think why it would be a problem. The loader is a single file that then loads a version-specific loader, which then loads the necessary modules of the specific version. But all that is irrelevant if google.charts.load is not defined in the first place because google.charts is not defined. Did the loader.js load, but fail to execute? Or is the loading still pending? It would be good to check the debugger 'network' tab to see what happened to the loading of loader.js. If I were in your situation, I would just try to work around the problem, maybe by checking whether google.charts is defined before calling google.charts.load. If it is not defined, call it again in a timeout. If it fails after a few such timeouts, there is probably something more serious going on, such as a failure during execution of the loader. Hope that helps. On Mon, Jul 1, 2019 at 12:00 PM James Handley <[email protected]> wrote: > Hi Daniel, > > Thank you for getting back to me so quickly - yes, I had forgotten to > include the <script> tag in the code I posted above, sorry. > > Good to be able to eliminate the throttling, and like you I didn't think > the of the javascript would execute until all the scripts were loaded (or > failed to load)... > My working theory is that either the 'loader.js' is failing to load at > all, or a corrupt version has been cached somewhere - but I want to try and > eliminate other possibilities. > > The fly in the ointment is that it has been rock solid for the customer > for years, and suddenly started having problems since around 17th June, > which appear to have been steadily getting worse since then. There has been > no code deployment at our end, and we are not aware of any infrastructure > changes at the customer's end. > > On the other hand, we so far haven't seen it happen from our network. > > Getting the client to refresh the page sometimes (but not always) fixes > the issue. > > It's not going to be so easy to point you at the web-page, as it's a > customer specific and commercially sensitive application. Is there anything > specific you'd be looking for? It might be possible to spin up a test > environment if that will shed any light. > > The only two google 'namespaces' the app references are 'google.maps' and > 'google.charts'. > > The site has been built in TypeScript, and the compiled JS gets bundled by > ASP.Net. > > The only bits of code which reference google charts/visualization are: > > *packages.config*: > <package id="google.visualization.TypeScript.DefinitelyTyped" > version="0.5.7" targetFramework="net452" /> > > *chart.html:* > <div class="chartDiv"> > </div> > > *chart.ts*: > namespace XXXX { > export class Chart { > element; > > constructor(ele: JQuery) { > this.element = ele; > var me = this; > this.element.load('Content/Chart.html', () => me.initialise()); > } > > private isChartsLoaded: boolean; > > private chartData: google.visualization.DataTable; > private classicChart: google.visualization.ColumnChart; > private chartOptions: google.visualization.ColumnChartOptions; > > private initialise() { > var me = this; > > me.isChartsLoaded = false; > > // Set a callback to run when the Google Visualization API is > loaded. > > // --- This line sometimes throws the exception > --- > google.charts.load('current', { 'packages': ['corechart'] }); > > google.charts.setOnLoadCallback(() => { > me.isChartsLoaded = true; > me.drawChart(); > window.addEventListener('resize', function (e) { > if (me.classicChart && me.chartData && me.chartOptions) > me.classicChart.draw(me.chartData, > me.chartOptions); > }); > }); > } > > private drawChart() { > > // .. removed code checking for data .. > > if (!this.isChartsLoaded || (typeof google === 'undefined') || > (typeof google.visualization === 'undefined')) { > // --- ... And after that we end up in > here whenever drawChart is called. --- > logger.warn('google.visualization hasn\'t loaded yet...'); > return; > } > > // .. removed code as it is never reached .. > } > } > } > > *MainPage.html:* > <!DOCTYPE html> > <html> > <head> > <meta charset="UTF-8"> > <title>XXXXX</title> > <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> > <META HTTP-EQUIV="Expires" CONTENT="-1"> > > * <!-- style sheets loaded here -->* > > <script src="bundles/jquery"></script> > <script type="text/javascript" src=" > https://www.gstatic.com/charts/loader.js"></script> > <script src=" > https://maps.googleapis.com/maps/api/js?client=XXX&channel=XXX"></script> > <script src="bundles/app-javascript"></script> > </head> > <body> > <!-- Various other widgets been removed for clarity, but none of them > use google charts --> > > <div id="chart" class="container"> > <div class="initialising">Please Wait</div> > </div> > </div> > > <script type="text/javascript"> > // -- other widgets removed > var chart; > > $(function () { > // -- other widgets removed > chart = new XXXX.Chart($('#chart')); > }); > </script> > </body> > </html> > > In the Chrome console, the only error reported is the TypeError, and I get > the same behaviour if I manually break the script reference(e.g. change it > to 'loader-broken.js') > > With thanks, > James > > -- > 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 [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > https://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/0f8a3f50-3c5c-4e75-984e-64707591b7f1%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/0f8a3f50-3c5c-4e75-984e-64707591b7f1%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> [email protected] <[email protected]> Cambridge MA -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJN-L-7tStGXFuxacTJR4PGoA4Pqx0S20xJxQMS0Qr8R3g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
