IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
290 stars 109 forks source link

[cache-details-on-map] TypeError while running hook mapDataEntityInject #103

Closed johnd0e closed 5 years ago

johnd0e commented 5 years ago

Sometimes I see this error in debug console:

error running hook mapDataEntityInject, error: TypeError: Cannot read property '2' of undefined

It occurs here: https://github.com/IITC-CE/ingress-intel-total-conversion/blob/d77562b91a5b1e0bf170b4257eb33316a0b9daa3/code/map_data_render.js#L109-L117

The function processGameEntities is called via hook:

https://github.com/IITC-CE/ingress-intel-total-conversion/blob/d77562b91a5b1e0bf170b4257eb33316a0b9daa3/code/map_data_request.js#L245

Hook is called from plugin.cachePortalDetailsOnMap.entityInject(data): https://github.com/IITC-CE/ingress-intel-total-conversion/blob/d77562b91a5b1e0bf170b4257eb33316a0b9daa3/plugins/cache-details-on-map.user.js#L24-L36

johnd0e commented 5 years ago

Error source found: https://github.com/IITC-CE/ingress-intel-total-conversion/blob/d77562b91a5b1e0bf170b4257eb33316a0b9daa3/plugins/cache-details-on-map.user.js#L20-L22

We need to check data.success here, because the same hook is called on failure too: https://github.com/IITC-CE/ingress-intel-total-conversion/blob/d77562b91a5b1e0bf170b4257eb33316a0b9daa3/code/portal_detail.js#L55-L61

And this leads to caching empty items, with ent property undefined.