The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): exit native admission probe after ConPTY shell completes
ethernet45b5f467d051
diff --git a/apps/desktop/scripts/probe-prepared-native.mjs b/apps/desktop/scripts/probe-prepared-native.mjsindex e829959486f..b1d86baf088 100644--- a/apps/desktop/scripts/probe-prepared-native.mjs+++ b/apps/desktop/scripts/probe-prepared-native.mjs@@ -32,8 +32,8 @@ async function probeChild(nativeDeps) {else resolve(undefined)})})- console.log(JSON.stringify({ electron: process.versions.electron, node: process.versions.node,- platform: process.platform, arch: process.arch, marker, exitCode: 0 }))+ fs.writeSync(1, JSON.stringify({ electron: process.versions.electron, node: process.versions.node,+ platform: process.platform, arch: process.arch, marker, exitCode: 0 }) + '\n')}/**@@ -71,6 +71,9 @@ export function probePreparedNative({ source, nativeDeps, packaging, out, nativeif (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {if (process.argv[2] === '--child') {await probeChild(path.resolve(process.argv[3]))+ // ConPTY can retain a worker after shell exit. This isolated probe has+ // completed its contract and synchronously flushed its result.+ process.exit(0)} else {const { values } = parseArgs({ options: {source: { type: 'string' }, 'native-deps': { type: 'string' }, packaging: { type: 'string' },diff --git a/apps/desktop/scripts/probe-prepared-native.test.mjs b/apps/desktop/scripts/probe-prepared-native.test.mjsindex fea41eca9a7..1094f9d7122 100644--- a/apps/desktop/scripts/probe-prepared-native.test.mjs+++ b/apps/desktop/scripts/probe-prepared-native.test.mjs@@ -1,7 +1,10 @@import assert from 'node:assert/strict'+import fs from 'node:fs'+import os from 'node:os'import { spawnSync } from 'node:child_process'import path from 'node:path'import { test } from 'vitest'+import { prepareDesktopNativeDependencies } from './stage-native-deps.mjs'test('the native admission child refuses ordinary Node instead of certifying an Electron ABI', () => {const child = spawnSync(process.execPath, [path.join(import.meta.dirname, 'probe-prepared-native.mjs'), '--child', import.meta.dirname], {@@ -10,3 +13,24 @@ test('the native admission child refuses ordinary Node instead of certifying anassert.notEqual(child.status, 0)assert.match(child.stderr, /Electron runtime required/)})++test.runIf(process.platform === 'win32')('the Electron PTY probe exits after its shell despite ConPTY workers', async () => {+ const source = path.resolve(import.meta.dirname, '../../..')+ const out = fs.mkdtempSync(path.join(os.tmpdir(), 'native-exit-'))+ try {+ const native = path.join(out, 'native')+ prepareDesktopNativeDependencies({ source, out: native })+ const { default: electron } = await import('electron')+ const child = spawnSync(electron, [path.join(import.meta.dirname, 'probe-prepared-native.mjs'), '--child', native], {+ cwd: out, encoding: 'utf8', timeout: 15000, env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },+ })+ assert.equal(child.error, undefined)+ assert.equal(child.status, 0, child.stderr)+ const result = JSON.parse(child.stdout)+ assert.equal(result.arch, process.arch)+ assert.equal(result.exitCode, 0)+ assert.match(result.marker, /^hermes-pty-/)+ } finally {+ fs.rmSync(out, { recursive: true, force: true })+ }+}, 30000)