You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am reporting an issue where the result of checkDiskSpace('/') could not be retrieved properly in the following environment:
Execution Environment:
Machine: AWS AppRunner
Node version: Node.js 18
Cause:
When executed in virtualized environments like AWS AppRunner (or Docker-based environments), there are cases where the Filesystem field in the df output is omitted. This causes the library to fail to parse the command output properly.
Workaround:
To address this issue, I implemented the following workaround by avoiding reliance on the Filesystem field:
const{ exec }=require('child_process');constutil=require('util');constexecPromise=util.promisify(exec);asyncfunctioncheckDiskFreeSpace(path){const{ stdout, stderr }=awaitexecPromise(`df -Pk -- ${path}`);if(stderr){thrownewError(`Unexpected result from df command: ${stderr}`);}// Parse the outputconstparsedLines=stdout.split('\n')// Split lines.map(line=>line.trim())// Trim all lines.filter(line=>line.length!==0)// Remove empty lines.slice(1)// Remove header.map(line=>line.split(/\s+(?=[\d/])/));// Split columns by whitespace before numbers or "/"if(parsedLines.length===0){thrownewError(`Unexpected result from df command: ${stdout}`);}returnparseInt(parsedLines[0][parsedLines[0].length-3],10)*1024;// Convert to bytes}
The text was updated successfully, but these errors were encountered:
Thank you for providing such a great library.
I am reporting an issue where the result of
checkDiskSpace('/')
could not be retrieved properly in the following environment:Execution Environment:
Cause:
When executed in virtualized environments like AWS AppRunner (or Docker-based environments), there are cases where the
Filesystem
field in thedf
output is omitted. This causes the library to fail to parse the command output properly.Example
df
output:Workaround:
To address this issue, I implemented the following workaround by avoiding reliance on the
Filesystem
field:The text was updated successfully, but these errors were encountered: