Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't stream (live) child_process stdout and stderr #2302

Closed
stavalfi opened this issue Nov 29, 2019 · 3 comments
Closed

Can't stream (live) child_process stdout and stderr #2302

stavalfi opened this issue Nov 29, 2019 · 3 comments

Comments

@stavalfi
Copy link
Contributor

Running this code from ava cli will not print anything from child-process:

const test = require('ava')
const { spawn } = require('child_process')

test('foo', t => {
  spawn('node', ['./example.js'], {
    stdio: 'inherit',
  })
  t.pass()
})

example.js

console.log("good1")
console.error("good2")

running the same logic without ava, will print as execpted

const { spawn } = require('child_process')

spawn('node', ['./example.js'], {
  stdio: 'inherit',
})

output:

good1
good2

command: ava --verbose
Node.js v10.15.0
darwin 18.7.0
2.4.0
6.5.0

I couldn't find any working solution in the issues

@novemberborn
Copy link
Member

With the example you give, the worker process may exit without giving the spawned process a chance to start. But I would expect this to work, yes.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@danielgormly
Copy link

danielgormly commented Oct 1, 2021

I also ran into an issue with using spawn (both sync and async versions). In a request with the software consul-template whose IO times out when an external connection can't be made. Running in Node directly or with a different test runner, everything happens as expected. Ava on the other hand, fails silently.

Node v16.1.0
Ava 3.15

@novemberborn
Copy link
Member

@danielgormly do you want to start a new discussion with more details about test setup and expected outcome?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants