a784cf4f2f57d30f1b1f789075e1bc07d1a0ad45
max
  Wed Dec 11 06:53:44 2024 -0800
fixing 32k cart string limit on Safari and Edge, refs #34911

diff --git src/hg/js/ajax.js src/hg/js/ajax.js
index c913857..c6e0b72 100644
--- src/hg/js/ajax.js
+++ src/hg/js/ajax.js
@@ -182,32 +182,32 @@
     var track = getTrack();
     if (track && track.length > 0)
         data = data + "&g=" + track;
     for(var ix=0; ix<names.length; ix++) {
         data = data + "&" + encodeURIComponent(names[ix]) + "=" + encodeURIComponent(values[ix]);
     }
     var type;
     // We prefer GETs so we can analyze logs, but use POSTs if data is longer than a
     // (conservatively small)  maximum length to avoid problems on older versions of IE.
     if ((loc.length + data.length) > 2000) {
         type = "POST";
     } else {
         type = "GET";
     }
 
-
-    if (!async || (typeof navigator.sendBeacon == 'undefined')) {
+    // on Safari and Edge, sendBeacon() has a limit of 32k, so fall back to ajax if the cart is very big
+    if (!async || (typeof navigator.sendBeacon == 'undefined' || data.length > 30000)) {
         // XmlHttpRequest is used for all synchronous updates and for async updates in IE,
         // because IE doesn't support sendBeacon.  If access to bowser is blocked, the default
         // is to assume the browser is not IE.
         $.ajax({
                    type: type,
                    async: async,
                    url: loc,
                    data: data,
                    trueSuccess: function () {},
                    success: catchErrorOrDispatch,
                    error: errFunc,
                    cache: false
                });
     }
     else {