diff --git a/config/scripts/desktop-distribution/runtime-verification/smoke-packaged-hang-watchdog-worker.mjs b/config/scripts/desktop-distribution/runtime-verification/smoke-packaged-hang-watchdog-worker.mjs index a8c4e578a8c..fd6d15422b9 100644 --- a/config/scripts/desktop-distribution/runtime-verification/smoke-packaged-hang-watchdog-worker.mjs +++ b/config/scripts/desktop-distribution/runtime-verification/smoke-packaged-hang-watchdog-worker.mjs @@ -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 }) } }