| 55 | let requestId = 0; |
| 56 | |
| 57 | async function get(url) { |
| 58 | const timeoutDuration = 2500; |
| 59 | const controller = new AbortController(); |
| 60 | let isError = false; |
| 61 | let responseText; |
| 62 | const timer = Utils.setTimeout(timeoutDuration, () => controller.abort()); |
| 63 | |
| 64 | try { |
| 65 | const response = await fetch(url, { signal: controller.signal }); |
| 66 | responseText = await response.text(); |
| 67 | } catch { |
| 68 | // Fetch throws an error if the network is unreachable, etc. |
| 69 | isError = true; |
| 70 | } |
| 71 | |
| 72 | clearTimeout(timer); |
| 73 | |
| 74 | return isError ? null : responseText; |
| 75 | } |
| 76 | |
| 77 | // Look up the completion engine for this searchUrl. |
| 78 | function lookupEngine(searchUrl) { |