Skip to content

Commit

Permalink
improve-worker-desktop-exit
Browse files Browse the repository at this point in the history
  • Loading branch information
maidh91 committed Dec 4, 2024
1 parent 26c9db4 commit aaff4d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { isMac, isWindows, isLinux } = require('which-runtime')
const constants = require('./constants')
const State = require('./state')
const API = require('./lib/api')
const Worker = require('./lib/worker')
const {
ERR_INVALID_APPLING,
ERR_PERMISSION_REQUIRED,
Expand Down Expand Up @@ -143,6 +144,14 @@ module.exports = async function run ({ ipc, args, cmdArgs, link, storage, detach
cwd,
...{ env: { ...ENV, NODE_PRESERVE_SYMLINKS: 1 } }
})

const worker = new Worker()
const pipe = worker.pipe()
if (pipe) {
pipe.on('end', () => child.kill())
pipe.on('close', () => child.kill())
}

child.once('exit', (code) => {
stream.push({ tag: 'exit', data: { code } })
ipc.close()
Expand Down

0 comments on commit aaff4d4

Please sign in to comment.