tanem / svg-injector

:syringe: Fast, caching, dynamic inline SVG DOM injection library.
https://npm.im/@tanem/svg-injector
MIT License
100 stars 14 forks source link

requestQueue[url].length is not defined #1498

Open Cordazar opened 6 days ago

Cordazar commented 6 days ago

I have tens of thousands issues monthly in my error monitoring tool for the issue below. No idea why it ends up this way and haven't been able to reproduce it locally. Do you have any ideas or suggestions?

TypeError: Cannot read properties of undefined (reading 'length')
 at ../../node_modules/@tanem/svg-injector/dist/svg-injector.esm.js(processRequestQueue:78:43)
 at ../../node_modules/@tanem/svg-injector/dist/svg-injector.esm.js(callback:104:5)
 at ../../node_modules/@tanem/svg-injector/dist/svg-injector.esm.js(o.onreadystatechange:41:9)
 var processRequestQueue = function processRequestQueue(url) {
  var _loop_1 = function _loop_1(i, len) {
    setTimeout(function () {
      if (Array.isArray(requestQueue[url])) {
        var cacheValue = cache.get(url);
        var callback = requestQueue[url][i];
        if (cacheValue instanceof SVGSVGElement) {
          callback(null, cloneSvg(cacheValue));
        }
        if (cacheValue instanceof Error) {
          callback(cacheValue);
        }
        if (i === requestQueue[url].length - 1) {
          delete requestQueue[url];
        }
      }
    }, 0);
  };
  for (var i = 0, len = requestQueue[url].length; i < len; i++) { //** This is line 78 **//
    _loop_1(i);
  }
};
Cordazar commented 3 days ago

ping @tanem