Skip to content

Commit

Permalink
🐛 PSProcess stderr handler was being registered more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinGrote committed Sep 25, 2021
1 parent 5d49a6c commit 52b36ef
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/powershell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ export class PowerShell {
'-Command',
'-'
])
// Warn if we have more than one listener set on a process
this.psProcess.stdout.setMaxListeners(2)
this.psProcess.stderr.setMaxListeners(1)
// TODO: More robust stderr handling
this.psProcess.stderr.once('data', (data: Buffer) => {
throw new Error(
`Error Received on stderr from pwsh: ` + data.toString()
)
})

if (!this.psProcess.pid) {
throw new Error(`Failed to start PowerShell process.`)
}
Expand Down Expand Up @@ -204,11 +214,6 @@ export class PowerShell {
createSplitPSOutputStream(psOutput)
])

// TODO: More robust stderr handling
this.psProcess.stderr.once('data', (data: Buffer) => {
throw new Error(`Error Received on stderr from pwsh: ` + data.toString())
})

const runnerScriptPath = resolve(
__dirname,
'..',
Expand Down

0 comments on commit 52b36ef

Please sign in to comment.