| 1 | // A core that dies while its host is stuck: starts a host in its own process |
| 2 | // group, activates a plugin, starts a tool call that never yields the event |
| 3 | // loop, prints the host pid, and exits without closing anything cleanly. |
| 4 | import { writeFileSync, mkdtempSync } from 'node:fs' |
| 5 | import { tmpdir } from 'node:os' |
| 6 | import { join } from 'node:path' |
| 7 | import { activate, startHost } from '../harness.mjs' |
| 8 | |
| 9 | const dir = mkdtempSync(join(tmpdir(), 'cw-ext-host-dying-')) |
| 10 | const entry = join(dir, 'index.mjs') |
| 11 | writeFileSync( |
| 12 | entry, |
| 13 | `export const name = 'spin' |
| 14 | export const inject = ['tools'] |
| 15 | export function apply(ctx) { |
| 16 | ctx.tools.register({ name: 'spin', description: '', parameters: { type: 'object', properties: {} }, execute: () => { for (;;) {} } }) |
| 17 | } |
| 18 | `, |
| 19 | ) |
| 20 | const host = await startHost({ ownGroup: true }) |
| 21 | const { result } = await activate(host, 'spin', entry) |
| 22 | if (result.status !== 'ok') throw new Error(JSON.stringify(result)) |
| 23 | const handle = host.registry.find((entry) => entry.op === 'register').handle |
| 24 | host.request('tool/call', { handle, call_id: 'spin', input: {}, deadline_ms: 60_000 }) |
| 25 | setTimeout(() => { |
| 26 | process.stdout.write(`${host.child.pid}\n`, () => process.exit(0)) |
| 27 | }, 200) |
| 28 |