Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

error within chunking iterator: TypeError: a.remove is not a function #1652

Closed
maeishoj opened this issue Dec 13, 2015 · 26 comments
Closed

error within chunking iterator: TypeError: a.remove is not a function #1652

maeishoj opened this issue Dec 13, 2015 · 26 comments
Labels

Comments

@maeishoj
Copy link

Hello everyone,

I am having a strange issue and i don't know what to make of it (see title).

That happen when I drop the a 2nd marker on the map, and if I drop say 5 and I try to click on each marker to open the InfoWindow, it only opens it for the first 2 markers and not the other ones.

screen shot 2015-12-13 at 15 02 43

I tried to reproduce it on plunkr, but wasn't able, as there it works just fine. I copied the whole code (relevant parts) and on my machine the same doesn't work properly.

http://plnkr.co/edit/qboJnHGORg4EQWZ6WG9B?p=preview

I am using 2.2.1 and if load 2.1.5 instead, i don't get that error!

DOes anyone have an idea what's going on?

@nmccready
Copy link
Contributor

Need an example where this is happening; but you would probably get better error information if you are not using minified code. (This is assumed, so if I am wrong apologies up front.)

@maeishoj
Copy link
Author

not sure why it said : angular-google-maps.min.js cause im not using minified and I checked again now and the error is the same, just without .min.

as I wrote above, unfortunately i tried to reproduce the error in plnkr, but i couldn't :/ IT is the same code and libraries i have locally, except a whole other bunch of libraries I have for my project that are not related but not sure whether they would cause incompatibility problems :/

From the error do you have any idea of what would be going wrong with the 2.2.1 that didn't with the 2.1.5 when I drop markers on the map (again, the error happens as I drop the 2nd marker on the map :( )

@nmccready
Copy link
Contributor

I don't know if it is an error per-say in the library. It means that some object a (which I do not see anywhere) is calling a function remove while iterating through the code. This error could be happening as high as the application level and just being caught in the iterator itself. Remove is called here and here

@nmccready
Copy link
Contributor

But bottom line is I can't really help without an example that actually produces the problem.

@maeishoj
Copy link
Author

I understand. I will try to see how i can reproduce this, else I will keep 2.1.5 unitll i can figure out how to reproduce it.

@nmccready
Copy link
Contributor

You don't have anything that is expected to be bound to remove do u? IE an attribute that is someAttr=" 'remove' " .

@nmccready
Copy link
Contributor

Also disable chunking with chunk=false and you might get a better stack trace.

@maeishoj
Copy link
Author

no remove. I am dropping marker from outside to the map, by adding the selected img to the array that is binded to the markers in the map and then do $scope.$apply(); else the markers are not shown on map. If I remove $scope.$apply() and drag and drop them, i get no error (right away), but no marker visible, but if then I move the map, so that its "refreshed" then i get the same error.

Also chunck =false didnt really help :/

screen shot 2015-12-14 at 17 25 00

@maeishoj
Copy link
Author

similar error but more descriptive happen in another page of my app (with 2.2.1 but no 2.1.5) and seems to relate to same issue, except it gives a little more details

screen shot 2015-12-14 at 17 37 12

@nmccready
Copy link
Contributor

Much better then it is a bug or something with an event listener being removed.

@nmccready nmccready reopened this Dec 14, 2015
@maeishoj
Copy link
Author

you are right, i think.

I have the following:

<ui-gmap-windows show="'show'">
                        <div ng-non-bindable>{{code}} - {{description}}<br/><strong>Location:</strong> {{latitude}} - {{longitude}} </div>
                        </ui-gmap-windows>

and I i remove the code above, not having a window, it works fine without throwing that error :/

@nmccready
Copy link
Contributor

Probably this for in is the problem.

https://github.com/angular-ui/angular-google-maps/blob/2.2.1/dist/angular-google-maps.js#L939

Are you extending Array.prototype ?

@nmccready
Copy link
Contributor

Anyway using _.each, angular.each or [].each might fix the problem but they are all slower. Also checking for hasOwnProperty would help as well.

@maeishoj
Copy link
Author

I do extend it but i can remove that. however i have a library bluebird.js from the template i am using, which i saw extends Array.prototype.

About the _.each, angular.each, [].each, how did you suggest me to use them (meaning, where)?

Also the last screenshot i posted where you said "much better" was from safari. Chrome (in the same page) doesn't throw that same error.

and another page again, gives a similar error right off the bat:

TypeError: a.remove is not a function
at Object._.G.removeListener (js:82)
at Object.angular.module.service.$log.removeEvents (angular-google-maps.js:945)
at angular-google-maps.js:6507
at n.a.$get.n.$broadcast (angular.js:14785)
at n.a.$get.n.$destroy (angular.js:14405)
at cleanupLastView (angular-route.js:843)
at angular-route.js:876
at angular.js:6995
at b.$get.h (angular.js:7135)
at k (angular.js:7795)

@nmccready
Copy link
Contributor

It is just me making notes on what I need to change in the code base. Nothing you can do. Its a bug and all of those are fixes. But you can test and confirm my assumptions by trying those changes directly in your angular-google-maps.js verison modified with one of those ideas.

@nmccready nmccready added the bug label Dec 14, 2015
@maeishoj
Copy link
Author

hey there. so removing my custom method of "array.prototype" fixed all issues so far for what i have seen. :)

@nmccready
Copy link
Contributor

Cool, yeah so whatever that prototype was was being passed to google as an object to remove which.. does not have the function remove. Make sense? Mucking with Array.prototype is a big no no.. but my for in loop should check for hasOwnProperty anyway.

@nmccready
Copy link
Contributor

So its kinda bug on two fronts.. one I need a better iterator or saftey check .. 2 (your side) you should be more careful with your prototypes :) .

@maeishoj
Copy link
Author

You right :) will keep that in mind :) I guess I can close the issue now! :)

Thanks again for the help! was useful to pinpoint the issue! :)

@nmccready
Copy link
Contributor

Going to keep it open as I won't remember to make that fix without this existing.

@maeishoj
Copy link
Author

ok ill reopen it!

@maeishoj maeishoj reopened this Dec 14, 2015
nmccready added a commit that referenced this issue Dec 14, 2015
@nmccready
Copy link
Contributor

resolved

@getglad
Copy link

getglad commented Jan 20, 2016

Can you package this as part of a release so it is available on NPM?

@nmccready
Copy link
Contributor

Yes I'll get this started. I think it will be 2.3.0 as there were possible breaking changes in uiGmapGoogleMapApi . Its better to bump to 2.3.X and be safe.

@nmccready
Copy link
Contributor

@getglad
Copy link

getglad commented Jan 29, 2016

@nmccready great - thanks so much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants