Skip to content

Ensure we use backoff when request fails #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions packages/labextension/src/memoryUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export namespace MemoryUsage {
*/
constructor(options: Model.IOptions) {
super();
this._poll = new Poll<Private.IMetricRequestResult | null>({
this._poll = new Poll<Private.IMetricRequestResult>({
factory: () => Private.factory(),
frequency: {
interval: options.refreshRate,
Expand Down Expand Up @@ -216,7 +216,7 @@ export namespace MemoryUsage {
private _currentMemory = 0;
private _memoryLimit: number | null = null;
private _metricsAvailable = false;
private _poll: Poll<Private.IMetricRequestResult | null>;
private _poll: Poll<Private.IMetricRequestResult>;
private _units: MemoryUnit = 'B';
private _warn = false;
}
Expand Down Expand Up @@ -328,18 +328,14 @@ namespace Private {
/**
* Make a request to the backend.
*/
export async function factory(): Promise<IMetricRequestResult | null> {
export async function factory(): Promise<IMetricRequestResult> {
const request = ServerConnection.makeRequest(
METRIC_URL,
{},
SERVER_CONNECTION_SETTINGS
);
const response = await request;

if (response.ok) {
return await response.json();
}

return null;
return await response.json();
}
}