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;
|
||||
|
||||
return new Promise<V>((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]
|
||||
|
Loading…
Reference in New Issue
Block a user