BackendSrv: Use uuid v4 as an identifier instead of Date.now() (#27176)

This commit is contained in:
Simon Podlipsky
2020-08-25 08:58:21 +02:00
committed by GitHub
parent cd9a773427
commit 84eb03e7e5
3 changed files with 14 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import { from, merge, MonoTypeOperatorFunction, Observable, Subject, Subscription, throwError } from 'rxjs';
import { catchError, filter, map, mergeMap, retryWhen, share, takeUntil, tap, throwIfEmpty } from 'rxjs/operators';
import { fromFetch } from 'rxjs/fetch';
import { v4 as uuidv4 } from 'uuid';
import { BackendSrv as BackendService, BackendSrvRequest, FetchError, FetchResponse } from '@grafana/runtime';
import { AppEvents } from '@grafana/data';
@@ -66,8 +67,7 @@ export class BackendSrv implements BackendService {
fetch<T>(options: BackendSrvRequest): Observable<FetchResponse<T>> {
return new Observable(observer => {
// We need to match an entry added to the queue stream with the entry that is eventually added to the response stream
// using Date.now() as the unique identifier
const id = Date.now().toString(10);
const id = uuidv4();
// Subscription is an object that is returned whenever you subscribe to an Observable.
// You can also use it as a container of many subscriptions and when it is unsubscribed all subscriptions within are also unsubscribed.