The resilientOverpassFetch function was creating setTimeout timers for each
Overpass server attempt without cleaning them up. These timers accumulated
in Node.js's event loop, causing memory to grow until the process crashed with
'JavaScript heap out of memory' error approximately every 6 minutes.
Fix:
- Track all timeout IDs in a timeoutIds array
- Add cleanup() function to clearTimeout on all tracked IDs
- Call cleanup() on success, failure, and when falling back to pending fetches
- Also fix clearInterval in useSearchLocalTransit to use interval ID instead of function
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe vibe@mistral.ai
The resilientOverpassFetch function was creating setTimeout timers for each
Overpass server attempt without cleaning them up. These timers accumulated
in Node.js's event loop, causing memory to grow until the process crashed with
'JavaScript heap out of memory' error approximately every 6 minutes.
Fix:
- Track all timeout IDs in a timeoutIds array
- Add cleanup() function to clearTimeout on all tracked IDs
- Call cleanup() on success, failure, and when falling back to pending fetches
- Also fix clearInterval in useSearchLocalTransit to use interval ID instead of function
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>