diff --git a/packages/grafana-ui/src/components/Combobox/useLatestAsyncCall.ts b/packages/grafana-ui/src/components/Combobox/useLatestAsyncCall.ts index df6747ebab9..0b1a4916a24 100644 --- a/packages/grafana-ui/src/components/Combobox/useLatestAsyncCall.ts +++ b/packages/grafana-ui/src/components/Combobox/useLatestAsyncCall.ts @@ -15,14 +15,16 @@ export function useLatestAsyncCall(fn: AsyncFn): AsyncFn { const requestCount = latestValueCount.current; return new Promise((resolve, reject) => { - fn(value).then((result) => { - // Only resolve if the value is still the latest - if (requestCount === latestValueCount.current) { - resolve(result); - } else { - reject(new StaleResultError()); - } - }); + fn(value) + .then((result) => { + // Only resolve if the value is still the latest + if (requestCount === latestValueCount.current) { + resolve(result); + } else { + reject(new StaleResultError()); + } + }) + .catch(reject); }); }, [fn]