Fix/deprioritize image requests (#638)

* Use "fetch" instead of "axios"

Axios does not support prioritizing requests

* Deprioritize image requests

The browser requests images (<img>) with low priority by default.
Due to switching to loading images via axios (f852ce70e7), the image requests had the same priority as other requests and thus blocked e.g. xhr requests
This commit is contained in:
schroda
2024-03-05 02:07:05 +01:00
committed by GitHub
parent 0f3549ead9
commit daf6b50249
6 changed files with 45 additions and 109 deletions

View File

@@ -6,7 +6,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { AxiosInstance } from 'axios';
import {
ApolloError,
ApolloQueryResult,
@@ -370,13 +369,13 @@ export class RequestManager {
return this.restClient;
}
public updateClient(config: Partial<AxiosInstance['defaults']>): void {
public updateClient(config: RequestInit): void {
this.restClient.updateConfig(config);
this.graphQLClient.updateConfig();
}
public getBaseUrl(): string {
return this.restClient.getClient().defaults.baseURL!;
return this.restClient.getBaseUrl();
}
public getValidUrlFor(endpoint: string, apiVersion: string = RequestManager.API_VERSION): string {
@@ -764,8 +763,13 @@ export class RequestManager {
const response = this.restClient
.fetcher(url, {
checkResponseIsJson: false,
config: { signal, responseType: 'blob' },
config: {
signal,
// @ts-ignore - typing has not been updated yet
priority: 'low',
},
})
.then((data) => data.blob())
.then((data) => URL.createObjectURL(data));
return { response, abortRequest };