|
|
@ -4,10 +4,10 @@ import 'accessible-autocomplete/dist/accessible-autocomplete.min.css' |
|
|
|
|
|
|
|
|
|
|
|
const options = [] |
|
|
|
const options = [] |
|
|
|
|
|
|
|
|
|
|
|
let latestQueryId = 0; |
|
|
|
let latestQueryId = 0 |
|
|
|
|
|
|
|
|
|
|
|
const sleep = (ms) => { |
|
|
|
const sleep = (ms) => { |
|
|
|
return new Promise(resolve => setTimeout(resolve, ms)); |
|
|
|
return new Promise(resolve => setTimeout(resolve, ms)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fetchOptions = async (query, searchUrl) => { |
|
|
|
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
|
|
|
|
// 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
|
|
|
|
// making too many requests can overwhelm the number of threads available on the server
|
|
|
|
// which can in turn cause a site wide outage
|
|
|
|
// which can in turn cause a site wide outage
|
|
|
|
latestQueryId++; |
|
|
|
latestQueryId++ |
|
|
|
const myQueryId = latestQueryId; |
|
|
|
const myQueryId = latestQueryId |
|
|
|
await sleep(500); |
|
|
|
await sleep(500) |
|
|
|
if (myQueryId !== latestQueryId) { |
|
|
|
if (myQueryId !== latestQueryId) { |
|
|
|
throw new Error('Outdated query, ignoring result.'); |
|
|
|
throw new Error('Outdated query, ignoring result.') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|