mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
GrafanaUI: Fix error handling from rejected promises in Combobox (#99478)
fix error handling not actually catching rejected promises from options fn
This commit is contained in:
parent
5da15ccdc4
commit
df024793d8
@ -15,14 +15,16 @@ export function useLatestAsyncCall<T, V>(fn: AsyncFn<T, V>): AsyncFn<T, V> {
|
|||||||
const requestCount = latestValueCount.current;
|
const requestCount = latestValueCount.current;
|
||||||
|
|
||||||
return new Promise<V>((resolve, reject) => {
|
return new Promise<V>((resolve, reject) => {
|
||||||
fn(value).then((result) => {
|
fn(value)
|
||||||
|
.then((result) => {
|
||||||
// Only resolve if the value is still the latest
|
// Only resolve if the value is still the latest
|
||||||
if (requestCount === latestValueCount.current) {
|
if (requestCount === latestValueCount.current) {
|
||||||
resolve(result);
|
resolve(result);
|
||||||
} else {
|
} else {
|
||||||
reject(new StaleResultError());
|
reject(new StaleResultError());
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.catch(reject);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[fn]
|
[fn]
|
||||||
|
Loading…
Reference in New Issue
Block a user