mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
Service capture cleanup in packaged watchdog smoke
This commit is contained in:
+10
-4
@@ -85,14 +85,13 @@ async function runInternal() {
|
||||
const tempRoot = mkdtempSync(join(tmpdir(), 'orca-packaged-watchdog-smoke-'))
|
||||
const markerPath = join(tempRoot, 'main-thread-hang.json')
|
||||
const entryPath = join(appAsar, 'out', 'main', 'main-thread-hang-watchdog-entry.js')
|
||||
let worker
|
||||
try {
|
||||
await app.whenReady()
|
||||
if (!existsSync(entryPath)) {
|
||||
throw new Error(`Packaged watchdog entry is missing from app.asar: ${entryPath}`)
|
||||
}
|
||||
const workerError = { current: null }
|
||||
worker = new Worker(entryPath, {
|
||||
const worker = new Worker(entryPath, {
|
||||
workerData: {
|
||||
parentPid: process.pid,
|
||||
markerPath,
|
||||
@@ -103,15 +102,22 @@ async function runInternal() {
|
||||
worker.once('error', (error) => {
|
||||
workerError.current = error
|
||||
})
|
||||
worker.on('message', (message) => {
|
||||
if (
|
||||
message?.type === 'capture-drain' &&
|
||||
typeof message.token === 'string' &&
|
||||
message.token.length <= 80
|
||||
) {
|
||||
setImmediate(() => worker.postMessage({ type: 'capture-drain-ack', token: message.token }))
|
||||
}
|
||||
})
|
||||
await waitForMarker(markerPath, (marker) => marker?.selfRecovered === false, workerError)
|
||||
worker.postMessage({ type: 'heartbeat' })
|
||||
await waitForMarker(markerPath, (marker) => marker?.selfRecovered === true, workerError)
|
||||
worker.postMessage({ type: 'shutdown' })
|
||||
await waitForExit(worker, workerError)
|
||||
worker = undefined
|
||||
console.log(SUCCESS_LINE)
|
||||
} finally {
|
||||
await worker?.terminate()
|
||||
rmSync(tempRoot, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user