Skip to content

Separate stdout and stderr in runExec #954

@joshtrichards

Description

@joshtrichards

runExec currently merges stdout and stderr into the same PassThrough stream:

exec.modem.demuxStream(stream, dataStream, dataStream)

Ideally we separate them.

This would allow us to capture error output - e.g. from occ - separately when we care about it.

Then we could make some scenarios like the docker-modem workaround in runOcc more robust:

// Build app list
const json = await runOcc(['app:list', '--output', 'json'], { container })
// fix dockerode bug returning invalid leading characters
const applist = JSON.parse(json.substring(json.indexOf('{')))

e.g.:

const { stdout, stderr } = await runOcc(['app:list', '--output', 'json'], { container })
if (stderr.trim()) {
  console.warn(`├─ occ stderr: ${stderr.trim()}`)
}
// Strip any residual binary header bytes from stdout only (docker-modem demuxing bug)
const cleaned = stdout.replace(/^[\x00-\x08\x0e-\x1f]+/, '')
const applist = JSON.parse(cleaned)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions