I have seen https://github.com/dagger/dagger/issues/5124 and know some changes to this are coming but wondering:
- For now what is the best way to get the stdout of a failed command and continue execution using the JS dagger SDK? Is it to just .catch() and pull
err.stdoutoff theExecError? - Any idea on timeline for the improved API, and its unclear to me if the new API will allow for things like capturing stdout of a failed command or just let you access
exitCodeif that is all you care about?
This is a pretty standard pattern in CI to have a job fail and handle the error in some way so trying to figure out how to properly handle this.
Right now when running
const errorsStdout = await node()
.withExec([
"./node_modules/.bin/tsc",
"-p",
"./tsconfig.json",
"--noEmit",
])
.stdout();
console.log("this never runs");
for example the file just bails at .stdout() we never see "this never runs" and outputs this error:
14: exec docker-entrypoint.sh ./node_modules/.bin/tsc -p ./tsconfig.json --noEmit ERROR: process "docker-entrypoint.sh ./node_modules/.bin/tsc -p ./tsconfig.json --noEmit" did not complete successfully: exit code: 2
file:///Users/ianownbey/code/web/node_modules/@dagger.io/dagger/dist/api/utils.js:5
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
^
ExecError: process "docker-entrypoint.sh ./node_modules/.bin/tsc -p ./tsconfig.json --noEmit" did not complete successfully: exit code: 2
at file:///Users/ianownbey/code/web/node_modules/@dagger.io/dagger/dist/api/utils.js:148:27
at Generator.throw (<anonymous>)
at rejected (file:///Users/ianownbey/code/web/node_modules/@dagger.io/dagger/dist/api/utils.js:5:65)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: undefined,
code: 'D109',
cmd: [
'docker-entrypoint.sh',
'./node_modules/.bin/tsc',
'-p',
'./tsconfig.json',
'--noEmit'
],
exitCode: 2,
stdout: "src/middleware.ts(15,59): error TS2322: Type 'string' is not assignable to type 'NextResponse<unknown>'.",
stderr: ''
}