server: DiskUsage: increase timeout to 5s

This commit is contained in:
Jesse Chan
2021-03-08 15:38:10 +08:00
parent f8c671fc9b
commit 287625782f
2 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ class DiskUsage extends (EventEmitter as new () => TypedEmitter<DiskUsageEvents>
return Promise.reject(new Error());
}
return diskUsage[process.platform as SupportedPlatform]()
return diskUsage[process.platform as SupportedPlatform](INTERVAL_UPDATE / 2)
.then((disks) => {
// Mountpoints with a very long path are unlikely to be useful.
return disks.filter((disk) => typeof disk.target === 'string' && disk.target.length < 30);
+9 -10
View File
@@ -36,12 +36,11 @@ const filterMountPoint = (mountpoint: string) => {
};
const MAX_BUFFER_SIZE = 65536;
const EXEC_TIMEOUT = 2000;
export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<Disk>>>> = {
linux: () =>
export const diskUsage: Readonly<Record<SupportedPlatform, (timeout: number) => Promise<Array<Disk>>>> = {
linux: (timeout) =>
spawnAsync('df', ['-T'], {
maxBuffer: MAX_BUFFER_SIZE,
timeout: EXEC_TIMEOUT,
timeout: timeout,
}).then((stdout) =>
stdout
.trim()
@@ -59,10 +58,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
};
}),
),
freebsd: () =>
freebsd: (timeout) =>
spawnAsync('df', [], {
maxBuffer: MAX_BUFFER_SIZE,
timeout: EXEC_TIMEOUT,
timeout: timeout,
}).then((stdout) =>
stdout
.trim()
@@ -79,10 +78,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
};
}),
),
darwin: () =>
darwin: (timeout) =>
spawnAsync('df', ['-kl'], {
maxBuffer: MAX_BUFFER_SIZE,
timeout: EXEC_TIMEOUT,
timeout: timeout,
}).then((stdout) =>
stdout
.trim()
@@ -99,10 +98,10 @@ export const diskUsage: Readonly<Record<SupportedPlatform, () => Promise<Array<D
};
}),
),
win32: () =>
win32: (timeout) =>
spawnAsync('wmic', ['logicaldisk'], {
maxBuffer: MAX_BUFFER_SIZE,
timeout: EXEC_TIMEOUT,
timeout: timeout,
}).then((stdout) =>
stdout
.trim()