-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
After 10 echo commands, the process appears to be blocked #434
Comments
With the stdio option added, it works as expected, But I still don't know why... const execa = require('execa')
const p = execa(
'powershell.exe',
[
'-NoLogo',
'-NoExit',
'-NoProfile',
'-ExecutionPolicy',
'ByPass',
],
+ { stdio: ['pipe', 'inherit', 'pipe'] }
)
let i = 0
setInterval(() => {
p.stdin.write(`echo ${i++}\n`)
}, 100) |
I ran more tests to try to find out why Work as expected: const EOL = require('os').EOL
const spawn = require('child_process').spawn
const p = spawn(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', 'pipe', 'pipe'] }
)
const arr = []
p.stdout.on('data', data => void arr.push(data.toString()))
let i = 0
const id = setInterval(() => {
p.stdin.write(`echo ${i++}${EOL}`)
}, 100)
setTimeout(() => {
clearInterval(id)
p.kill()
console.log(arr)
}, 3e3) Not working as expected: const EOL = require('os').EOL
const execa = require('execa')
const p = execa(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', 'pipe', 'pipe'] }
)
const arr = []
p.stdout.on('data', data => void arr.push(data.toString()))
let i = 0
const id = setInterval(() => {
p.stdin.write(`echo ${i++}${EOL}`)
}, 100)
setTimeout(() => {
clearInterval(id)
p.kill()
console.log(arr)
}, 3e3) Work as expected: const EOL = require('os').EOL
const execa = require('execa')
const fs = require('fs')
const out = fs.openSync('./out.log', 'a')
const p = execa(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', out, 'pipe'] }
)
let i = 0
const id = setInterval(() => {
p.stdin.write(`echo ${i++}${EOL}`)
}, 100)
setTimeout(() => {
clearInterval(id)
p.kill()
}, 3e3) Work as expected: const spawn = require('child_process').spawn
const p = spawn(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', 'pipe', 'pipe'] }
)
p.stdout.pipe(process.stdout)
let i = 0
setInterval(() => {
p.stdin.write(`echo ${i++}\n`)
}, 100) Not working as expected: const execa = require('execa')
const p = execa(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', 'pipe', 'pipe'] }
)
p.stdout.pipe(process.stdout)
let i = 0
setInterval(() => {
p.stdin.write(`echo ${i++}\n`)
}, 100) |
Hi @doublethinkio, Could you try adding the |
Hi @ehmicky As the picture shows, it seems to stop there forever, in the expectation that it will go on and on |
If I execute them 20 times in sync, they will work as expected Work as expected: const execa = require('execa')
const p = execa(
'powershell.exe',
['-NoLogo', '-NoExit', '-NoProfile', '-ExecutionPolicy', 'ByPass'],
{ stdio: ['pipe', 'pipe', 'pipe'] }
)
p.stdout.pipe(process.stdout)
let i = 0
while (i < 20) {
p.stdin.write(`echo ${i++}\n`)
} It seems to be an event loop related problem. |
This seems to happen for me aswell on Debian when running yarn with execa. |
Hello, |
It's very easy to reproduce the problem
If you replace PowerShell with CMD, it can last up to 15 times😅
Maybe I did something wrong?
The text was updated successfully, but these errors were encountered: