diff --git a/app/frontend/controllers/address_search_controller.js b/app/frontend/controllers/address_search_controller.js index 833bc317f..b3410e49d 100644 --- a/app/frontend/controllers/address_search_controller.js +++ b/app/frontend/controllers/address_search_controller.js @@ -4,10 +4,10 @@ import 'accessible-autocomplete/dist/accessible-autocomplete.min.css' const options = [] -let latestQueryId = 0; +let latestQueryId = 0 const sleep = (ms) => { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise(resolve => setTimeout(resolve, ms)) } const fetchOptions = async (query, searchUrl) => { @@ -19,11 +19,11 @@ const fetchOptions = async (query, searchUrl) => { // this is because this API has periods of high latency if OS Places has an outage // making too many requests can overwhelm the number of threads available on the server // which can in turn cause a site wide outage - latestQueryId++; - const myQueryId = latestQueryId; - await sleep(500); + latestQueryId++ + const myQueryId = latestQueryId + await sleep(500) if (myQueryId !== latestQueryId) { - throw new Error('Outdated query, ignoring result.'); + throw new Error('Outdated query, ignoring result.') } try {