This is a theoretical issue, as I didn't encounter it. But under some circumstances you pass undefined instead of an actual position.
When setTimeout calls stopTrying, you pass lastCheckedPosition to foundPosition, but lastCheckedPosition is undefined if watchPosition didn't deliver any positions. In an earlier version of this script you were instead correctly returning a TIMEOUT error.
Edit: oh, I don't think this was in a earlier version, but only in my local modified version.
This is a theoretical issue, as I didn't encounter it. But under some circumstances you pass
undefinedinstead of an actual position.When
setTimeoutcallsstopTrying, you passlastCheckedPositiontofoundPosition, butlastCheckedPositionis undefined ifwatchPositiondidn't deliver any positions. In an earlier version of this script you were instead correctly returning a TIMEOUT error.Edit: oh, I don't think this was in a earlier version, but only in my local modified version.