Skip to content

Commit

Permalink
improvement: explicitly catch EMFILE errors with better error message
Browse files Browse the repository at this point in the history
Another one in the series of potential errors when the project file
count is too high.

See issue #2003 for one reported case of this.
  • Loading branch information
edvald committed Sep 4, 2020
1 parent 9a42396 commit 37975c8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function makeErrorMsg({
${trimEnd(error, "\n")}
`
if (output !== error) {
if (output && output !== error) {
msg +=
lines.length > nLinesToShow
? `\n\nHere are the last ${nLinesToShow} lines of the output:`
Expand Down Expand Up @@ -175,11 +175,24 @@ export async function exec(cmd: string, args: string[], opts: ExecOpts = {}) {
const res = await proc
return res
} catch (err) {
if (err.code === "EMFILE" || err.errno === "EMFILE") {
throw new RuntimeError(
dedent`
Received EMFILE (Too many open files) error when running ${cmd}.
This may mean there are too many files in the project, and that you need to exclude large dependency directories. Please see https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories for information on how to do that.
This can also be due to limits on open file descriptors being too low. Here is one guide on how to configure those limits for different platforms: https://docs.riak.com/riak/kv/latest/using/performance/open-files-limit/index.html
`,
{ error: err }
)
}

const error = <execa.ExecaError>err
const message = makeErrorMsg({
cmd,
args,
code: error.exitCode,
code: error.exitCode || err.code || err.errno,
output: error.all || error.stdout || error.stderr || "",
error: error.stderr,
})
Expand Down

0 comments on commit 37975c8

Please sign in to comment.