danzel / Leaflet.utfgrid

A UTFGrid implementation for leaflet that is super small.
MIT License
132 stars 51 forks source link

Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node' #47

Open vjpr opened 9 years ago

vjpr commented 9 years ago

I receive this error ocassionally.

Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
  window.(anonymous function).(anonymous function) @ leaflet.utfgrid.js:257
  (anonymous function) @ tile.json?callback=lu0.lu_3_7_1:1

This is the code:

        window[wk][functionName] = function (data) {
            self._cache[key] = data;
            delete window[wk][functionName];
            head.removeChild(script); // <--
            self._finish_request(key);
        };
danzel commented 9 years ago

Are you getting timeouts loading tiles? Not sure how this happens, but maybe if loading is aborted and then it finishes loading?

syork commented 8 years ago

I'm getting this same issue. Doing some research leads me to believe it may have something to do with Angular.

remilev commented 8 years ago

I'm getting this issue too without Angular.

I think that head.removeChild(script) is sometimes executed twice. On second call, script is not in the head anymore and an error is thrown :

window[wk][functionName] = function (data) {
        self._cache[key] = data;
        delete window[wk][functionName];
        head.removeChild(script);
        self._finish_request(key);
    };
    this._queue_request(key, url, function () {
        head.appendChild(script);
        return {
            abort: function () {
                head.removeChild(script); // THIS LINE is executed BEFORE the other removeChild that is executed too. The issue is then ONLY showing when abort is requested.
            }
        };
    });

I'm not sure exactly WHEN ABORT is needed (when timeout occures then tiles were not completly loaded I think), but I'm getting this error when I zoomIn and immediately zoomOut. Not leaving enough time to load tiles correctly (but server serves 200 response code - no timeout problem).

It would probably worth testing if childNode exist before attempting deletion to avoid this error.

strk commented 7 years ago

We're also getting this error from the Windshaft example viewer: https://github.com/CartoDB/Windshaft/tree/master/examples/viewer

SergioGutTal commented 7 years ago

This fixed the problem for me Change

head.removeChild(script);

for

if (script.parentElement==head) {
  head.removeChild(script);
}