Skip to content

Commit c8154a9

Browse files
authored
Merge pull request #104 from jupyter-server/fix-poll-backoff
Ensure we use backoff when request fails
2 parents 6fa156f + f1e6464 commit c8154a9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

packages/labextension/src/memoryUsage.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export namespace MemoryUsage {
9393
*/
9494
constructor(options: Model.IOptions) {
9595
super();
96-
this._poll = new Poll<Private.IMetricRequestResult | null>({
96+
this._poll = new Poll<Private.IMetricRequestResult>({
9797
factory: () => Private.factory(),
9898
frequency: {
9999
interval: options.refreshRate,
@@ -216,7 +216,7 @@ export namespace MemoryUsage {
216216
private _currentMemory = 0;
217217
private _memoryLimit: number | null = null;
218218
private _metricsAvailable = false;
219-
private _poll: Poll<Private.IMetricRequestResult | null>;
219+
private _poll: Poll<Private.IMetricRequestResult>;
220220
private _units: MemoryUnit = 'B';
221221
private _warn = false;
222222
}
@@ -328,18 +328,14 @@ namespace Private {
328328
/**
329329
* Make a request to the backend.
330330
*/
331-
export async function factory(): Promise<IMetricRequestResult | null> {
331+
export async function factory(): Promise<IMetricRequestResult> {
332332
const request = ServerConnection.makeRequest(
333333
METRIC_URL,
334334
{},
335335
SERVER_CONNECTION_SETTINGS
336336
);
337337
const response = await request;
338338

339-
if (response.ok) {
340-
return await response.json();
341-
}
342-
343-
return null;
339+
return await response.json();
344340
}
345341
}

0 commit comments

Comments
 (0)