Closed smellyshovel closed 1 year ago
As it turned out, the reason was in a race-condition.
If there's a previously-ongoing request to fetch directions and the destroy()
method is called, it calls the setWaypoints()
method, which synchronously calls the asynchronous fetchDirections()
. When it's done and its finally
clause is invoked to restore the previous interactive state, if it was true
, it overwrites the interactive = false
from the destroy()
mehod and thus re-adds all the event listeners.
Since after destroy()
and setting the instance to undefined
the instance doesn't exist anymore, there are no layers anymore as well. And the move
callback tries to address layers that don't exist anymore.
Fixed in #190 by aborting the ongoing request with a special reason and only restoring the prev. interactive state when it's not that special reason.
When the
destrtoy()
method is called while the Directions is fetching the routes, that leads to multipleruntime errors. Seems like them come from themousemove
handler which is for some reason not detached after the plugin's layers are removed from the map (withdestroy()
).