Skip to content

Commit

Permalink
refactor: use try/finally
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 29, 2022
1 parent 3dd2841 commit 58698fa
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ export default class ChildProcessRunner {
},
)

const message = new Promise((res, rej) => {
childProcess.on('message', (data) => {
if (data.error) rej(data.error)
else res(data)
let message

try {
message = new Promise((res, rej) => {
childProcess.on('message', (data) => {
if (data.error) rej(data.error)
else res(data)
})
})
}).finally(() => {
} finally {
childProcess.kill()
})
}

childProcess.send({
context,
Expand Down

0 comments on commit 58698fa

Please sign in to comment.