Skip to content

Commit

Permalink
Make doubly sure that we have a stream
Browse files Browse the repository at this point in the history
  • Loading branch information
niik committed Nov 8, 2019
1 parent 0cffa88 commit 8cc0010
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/src/lib/git/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ function configureOptionsForRebase(

return merge(options, {
processCallback: (process: ChildProcess) => {
// If Node.js encounters a synchronous runtime error while spawning
// `stdout` will be undefined and the error will be emitted asynchronously
if (!process.stdout) {
return
}
const parser = new GitRebaseParser(rebasedCommitCount, totalCommitCount)

// rebase emits progress messages on `stdout`, not `stderr`
Expand Down
10 changes: 7 additions & 3 deletions app/src/lib/progress/from-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ function createProgressProcessCallback(
})
}

byline(process.stderr).on('data', (line: string) => {
progressCallback(parser.parse(line))
})
// If Node.js encounters a synchronous runtime error while spawning
// `stderr` will be undefined and the error will be emitted asynchronously
if (process.stderr) {
byline(process.stderr).on('data', (line: string) => {
progressCallback(parser.parse(line))
})
}
}
}

0 comments on commit 8cc0010

Please sign in to comment.