subagent-spawn.spec.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. import { describe, expect, it } from 'vitest'
  2. import { Context } from 'cordis'
  3. import Loader from '@cordisjs/plugin-loader'
  4. import LlmService from '@deepseek-ai/dsh-llm'
  5. import SessionStore from '@deepseek-ai/dsh-session'
  6. import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
  7. import ToolRegistry from '@deepseek-ai/dsh-tools'
  8. import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent'
  9. import { SessionId } from '@deepseek-ai/dsh-session'
  10. import AgentLoop from '@deepseek-ai/dsh-agent-loop'
  11. import * as Invariants from '@deepseek-ai/dsh-invariants'
  12. import SubagentService, { type SubagentStartRequest } from '@deepseek-ai/dsh-subagent'
  13. import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from '../../../core/agent-loop/tests/mock-adapter.ts'
  14. import * as spawn from '../src/index.ts'
  15. import { depthOf, STRUCTURED_OUTPUT_TOOL, SubagentDepthError } from '@deepseek-ai/dsh-subagent-inprocess'
  16. type Script = ConstructorParameters<typeof MockAdapter>[0]
  17. /**
  18. * Drives the REAL spawn backend end-to-end: a real agent loop + a scripted mock
  19. * MODEL (the only mocked boundary) + the real SubagentService + the real
  20. * dsh-invariants plugin (so a malformed child session log would fail the test).
  21. * The parent is a real config agent; the spawn provider creates a real child
  22. * agent on the same context and we assert its output.
  23. */
  24. async function setup(script: Script) {
  25. const ctx = new Context()
  26. const adapter = new MockAdapter(script)
  27. await ctx.plugin(LlmService)
  28. await ctx.plugin(SessionStore)
  29. await ctx.plugin(SystemPrompt)
  30. await ctx.plugin(ToolRegistry)
  31. await ctx.plugin(AgentRegistry)
  32. await ctx.plugin(Invariants)
  33. await ctx.plugin(AgentLoop, { agents: [] })
  34. await ctx.plugin(SubagentService)
  35. await ctx.plugin(spawn, { providerName: 'spawn' })
  36. ctx.llm.registerAdapter(['mock'], adapter)
  37. const parent = ctx.agentLoop.create(AgentId('parent'), { model: 'mock' })
  38. return { ctx, parent, adapter }
  39. }
  40. function text(blocks: { type: string; text?: string }[]): string {
  41. return blocks.filter(b => b.type === 'text').map(b => b.text).join('')
  42. }
  43. function start(ctx: Context, provider: string, request: Omit<SubagentStartRequest, 'signal'> & { signal?: AbortSignal }) {
  44. return ctx.subagents.start(provider, { signal: request.signal ?? new AbortController().signal, ...request })
  45. }
  46. describe('dsh-subagent-spawn', () => {
  47. it('runs a fresh child to completion and returns its final assistant output', async () => {
  48. // One model call for the child: a plain text answer.
  49. const { ctx, parent } = await setup([textResponse('child answer')])
  50. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'do X' }], parent })
  51. const result = await run.result
  52. expect(result.stopReason).toBe('completed')
  53. expect(text(result.output)).toBe('child answer')
  54. await run.dispose()
  55. })
  56. it('emits subagent/start only after the fresh child is published', async () => {
  57. const { ctx, parent } = await setup([textResponse('child answer')])
  58. let childAtStart: ReturnType<typeof ctx.agents.get>
  59. ctx.on('subagent/start', (info) => {
  60. if (info.provider === 'spawn') childAtStart = ctx.agents.get(info.id)
  61. })
  62. const starting = start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'do X' }], parent })
  63. // Creation is asynchronous; no lifecycle claim is made while the child is
  64. // still inside its unpublished setup transaction.
  65. expect(childAtStart).toBeUndefined()
  66. const run = await starting
  67. expect(childAtStart).toBe(ctx.agents.get(run.id))
  68. expect(childAtStart?.id).toBe(run.id)
  69. await run.result
  70. await run.dispose()
  71. })
  72. it('gives the child its OWN session (not the parent\'s), with parentSession lineage', async () => {
  73. const { ctx, parent } = await setup([textResponse('hi')])
  74. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  75. await run.result
  76. const child = ctx.agents.get(run.id)!
  77. expect(child.session.header.id).not.toBe(parent.session.header.id)
  78. expect(child.session.header.parentSession).toBe(parent.session.header.id)
  79. await run.dispose()
  80. })
  81. it('a fresh child does NOT inherit the parent conversation (its log starts empty before the prompt)', async () => {
  82. // Drive the parent through one real turn so it has history, THEN spawn.
  83. const { ctx, parent } = await setup([textResponse('parent turn'), textResponse('child sees nothing')])
  84. parent.send([{ type: 'text', text: 'parent prompt' }])
  85. await parent.whenIdle()
  86. const parentEventCount = parent.session.events.length
  87. expect(parentEventCount).toBeGreaterThan(0)
  88. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'child prompt' }], parent })
  89. await run.result
  90. const child = ctx.agents.get(run.id)!
  91. // The child's first user/message is its OWN prompt, not the parent's history.
  92. const firstUser = child.session.events.find(e => e.type === 'user/message')
  93. expect(firstUser).toBeDefined()
  94. await run.dispose()
  95. })
  96. it('disposes the child to quiescence (agent removed from the registry)', async () => {
  97. const { ctx, parent } = await setup([textResponse('x')])
  98. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  99. await run.result
  100. expect(ctx.agents.get(run.id)).toBeDefined()
  101. await run.dispose()
  102. // After dispose, the child is unregistered (the AgentHandle teardown ran).
  103. expect(ctx.agents.get(run.id)).toBeUndefined()
  104. })
  105. it('stamps child depth = parent depth + 1 (via the merged AgentOptions field)', async () => {
  106. const { ctx, parent } = await setup([textResponse('x')])
  107. expect(depthOf(parent)).toBe(0)
  108. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  109. await run.result
  110. const child = ctx.agents.get(run.id)!
  111. expect(depthOf(child)).toBe(1)
  112. await run.dispose()
  113. })
  114. it('refuses to spawn past maxDepth (depthLimit capability)', async () => {
  115. const { ctx, parent } = await setup([])
  116. // parent is depth 0, child would be depth 1 — cap at 0 forbids any child.
  117. await expect(start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, maxDepth: 0 }))
  118. .rejects.toThrow(SubagentDepthError)
  119. })
  120. it('maps a child that hit its token ceiling to stopReason "max-tokens"', async () => {
  121. const { ctx, parent } = await setup([maxTokensResponse('cut off')])
  122. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  123. const result = await run.result
  124. expect(result.stopReason).toBe('max-tokens')
  125. await run.dispose()
  126. })
  127. it('maps a child whose turn errored (script exhausted) to stopReason "error" with empty output', async () => {
  128. // Empty script: the child's first model call throws "script exhausted", the
  129. // turn ends `error`, and there is no assistant/message → empty output.
  130. const { ctx, parent } = await setup([])
  131. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  132. const result = await run.result
  133. expect(result.stopReason).toBe('error')
  134. expect(result.output).toEqual([])
  135. await run.dispose()
  136. })
  137. it('rejects without publishing when the request signal is already aborted', async () => {
  138. // An already-aborted signal emits no future event, so start must check it before listening and
  139. // settle aborted without running the child. The empty model script proves no turn occurs.
  140. const controller = new AbortController()
  141. controller.abort()
  142. const { ctx, parent } = await setup([])
  143. await expect(start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, signal: controller.signal }))
  144. .rejects.toThrow('aborted before child publication')
  145. })
  146. it('same-tick cancellation rejects start and prevents child publication', async () => {
  147. // Same-tick cancellation must win before async factory publication: no child may become
  148. // visible, `started` must not fulfill, and the empty script proves no model turn occurs.
  149. const { ctx, parent } = await setup([])
  150. const beforeAgents = ctx.agents.list().length
  151. const beforeSessions = ctx.sessions.list().length
  152. const published: string[] = []
  153. ctx.on('session/created', () => void published.push('session/created'))
  154. ctx.on('agent/created', () => void published.push('agent/created'))
  155. ctx.on('agent/session-start', () => void published.push('agent/session-start'))
  156. ctx.on('subagent/start', () => void published.push('subagent/start'))
  157. ctx.on('subagent/end', () => void published.push('subagent/end'))
  158. const controller = new AbortController()
  159. const starting = start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, signal: controller.signal })
  160. controller.abort('early')
  161. await expect(starting).rejects.toThrow()
  162. await Promise.resolve()
  163. expect(ctx.agents.list()).toHaveLength(beforeAgents)
  164. expect(ctx.sessions.list()).toHaveLength(beforeSessions)
  165. expect(published).toEqual([])
  166. })
  167. it('a cancel from agent/queued maps a no-turn child log to aborted', async () => {
  168. const { ctx, parent } = await setup([])
  169. const controller = new AbortController()
  170. ctx.on('agent/queued', () => { controller.abort('queued-window') })
  171. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, signal: controller.signal })
  172. const result = await run.result
  173. expect(result).toMatchObject({ stopReason: 'aborted', output: [] })
  174. const child = ctx.agents.get(run.id)!
  175. expect(child.session.events.some(event => event.type === 'turn/end')).toBe(false)
  176. await run.dispose()
  177. })
  178. it('cancelling a running child settles the run as aborted (the abort bridge + cancel())', async () => {
  179. // 'hang' makes the child's model stream one chunk then wait until aborted.
  180. const controller = new AbortController()
  181. const { ctx, parent } = await setup(['hang'])
  182. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, signal: controller.signal })
  183. // Let the child's turn start, then abort via the request signal (the
  184. // backend bridges it to child.cancel()).
  185. await new Promise(r => setTimeout(r, 30))
  186. controller.abort()
  187. const result = await run.result
  188. expect(result.stopReason).toBe('aborted')
  189. await run.dispose()
  190. })
  191. it('dispose cancels the child and reaches quiescence', async () => {
  192. const { ctx, parent } = await setup(['hang'])
  193. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  194. await new Promise(r => setTimeout(r, 30))
  195. await run.dispose()
  196. const result = await run.result
  197. expect(result.stopReason).toBe('aborted')
  198. })
  199. it('does not expose the optional runtime methods (sendMessage/resume) in this cut', async () => {
  200. const { ctx, parent } = await setup([textResponse('x')])
  201. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
  202. expect('sendMessage' in run).toBe(false)
  203. expect('resume' in run).toBe(false)
  204. await run.result
  205. await run.dispose()
  206. })
  207. it('inherits the parent cwd into the child session', async () => {
  208. const { ctx } = await setup([textResponse('x')])
  209. // A parent WITH a cwd (config agents have none, so create one explicitly).
  210. const parentHandle = await ctx.agents.create({
  211. agentId: AgentId('cwd-parent'),
  212. sessionId: SessionId('cwd-parent-session'),
  213. meta: { cwd: '/tmp/parent-workspace' },
  214. agentOptions: { model: 'mock' },
  215. })
  216. const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent: parentHandle.agent })
  217. await run.result
  218. const child = ctx.agents.get(run.id)!
  219. expect(child.session.header.cwd).toBe('/tmp/parent-workspace')
  220. await run.dispose()
  221. await parentHandle.dispose()
  222. })
  223. it('uses request.agentOptions.model when the parent has no model of its own', async () => {
  224. const { ctx } = await setup([textResponse('explicit model child')])
  225. // A parent with NO model (its own turns would need one supplied per-request).
  226. const parentHandle = await ctx.agents.create({
  227. agentId: AgentId('modelless-parent'),
  228. sessionId: SessionId('modelless-parent-session'),
  229. agentOptions: {},
  230. })
  231. // The request supplies the child's model explicitly.
  232. const run = await start(ctx, 'spawn', {
  233. prompt: [{ type: 'text', text: 'p' }],
  234. parent: parentHandle.agent,
  235. agentOptions: { model: 'mock' },
  236. })
  237. const result = await run.result
  238. expect(result.stopReason).toBe('completed')
  239. expect(text(result.output)).toBe('explicit model child')
  240. await run.dispose()
  241. await parentHandle.dispose()
  242. })
  243. it('advertises every start-time capability (depthLimit, outputSchema, toolFilter, persona)', async () => {
  244. const { ctx } = await setup([])
  245. const provider = ctx.subagents.getProvider('spawn')!
  246. expect(provider.capabilities).toEqual({ outputSchema: true, depthLimit: true, toolFilter: true, persona: true })
  247. })
  248. it('unregisters the provider when its fiber is disposed (HMR safety)', async () => {
  249. const ctx = new Context()
  250. await ctx.plugin(SubagentService)
  251. await ctx.plugin(AgentRegistry)
  252. const fiber = await ctx.plugin(spawn, { providerName: 'spawn' })
  253. expect(ctx.subagents.list()).toEqual(['spawn'])
  254. await fiber.dispose()
  255. expect(ctx.subagents.list()).toEqual([])
  256. })
  257. it('captures structured output through the shipped plugin (driver runtime, plugin wiring)', async () => {
  258. const { ctx, parent } = await setup([
  259. toolCallResponse('c1', STRUCTURED_OUTPUT_TOOL, { answer: 42 }),
  260. ])
  261. const run = await start(ctx, 'spawn', {
  262. prompt: [{ type: 'text', text: 'produce the answer' }],
  263. parent,
  264. outputSchema: { type: 'object', properties: { answer: { type: 'number' } }, required: ['answer'] },
  265. })
  266. const result = await run.result
  267. expect(result.stopReason).toBe('completed')
  268. expect(result.structured).toEqual({ answer: 42 })
  269. // Run-scoped runtime: the settle released the last acquisition.
  270. expect(ctx.tools.get(STRUCTURED_OUTPUT_TOOL)).toBeUndefined()
  271. await run.dispose()
  272. })
  273. it('a backend unload does not revoke an accepted holder-owned run', async () => {
  274. // Rebuild the stack by hand so we hold the backend's fiber.
  275. const ctx = new Context()
  276. const adapter = new MockAdapter(['hang'])
  277. await ctx.plugin(LlmService)
  278. await ctx.plugin(SessionStore)
  279. await ctx.plugin(SystemPrompt)
  280. await ctx.plugin(ToolRegistry)
  281. await ctx.plugin(AgentRegistry)
  282. await ctx.plugin(Invariants)
  283. await ctx.plugin(AgentLoop, { agents: [] })
  284. await ctx.plugin(SubagentService)
  285. const fiber = await ctx.plugin(spawn, { providerName: 'spawn' })
  286. ctx.llm.registerAdapter(['mock'], adapter)
  287. const parent = ctx.agentLoop.create(AgentId('parent'), { model: 'mock' })
  288. const controller = new AbortController()
  289. const run = await start(ctx, 'spawn', {
  290. prompt: [{ type: 'text', text: 'q' }],
  291. parent,
  292. signal: controller.signal,
  293. outputSchema: { type: 'object', properties: { a: { type: 'number' } } },
  294. })
  295. // Provider removal prevents new starts but the returned run belongs to its
  296. // holder and remains live.
  297. await new Promise(resolve => setTimeout(resolve, 30))
  298. await fiber.dispose()
  299. expect(ctx.subagents.getProvider('spawn')).toBeUndefined()
  300. expect(ctx.agents.get(run.id)).toBeDefined()
  301. controller.abort('test complete')
  302. const result = await run.result
  303. expect(result.stopReason).toBe('aborted')
  304. expect(ctx.tools.get(STRUCTURED_OUTPUT_TOOL)).toBeUndefined()
  305. await run.dispose()
  306. })
  307. it('a start racing an already-unloading backend cannot begin child creation', async () => {
  308. const ctx = new Context()
  309. await ctx.plugin(LlmService)
  310. await ctx.plugin(SessionStore)
  311. await ctx.plugin(SystemPrompt)
  312. await ctx.plugin(ToolRegistry)
  313. await ctx.plugin(AgentRegistry)
  314. await ctx.plugin(AgentLoop, { agents: [] })
  315. await ctx.plugin(SubagentService)
  316. const fiber = await ctx.plugin(spawn, { providerName: 'spawn' })
  317. const parent = ctx.agentLoop.create(AgentId('parent'), { model: 'mock' })
  318. const parentEffects = parent.ctx.fiber.getEffects().length
  319. const published: string[] = []
  320. ctx.on('session/created', () => void published.push('session/created'))
  321. ctx.on('agent/created', () => void published.push('agent/created'))
  322. const unloading = fiber.dispose()
  323. await unloading
  324. await expect(start(ctx, 'spawn', {
  325. prompt: [{ type: 'text', text: 'must never start' }], parent,
  326. })).rejects.toThrow(/no subagent provider/)
  327. expect(parent.ctx.fiber.getEffects()).toHaveLength(parentEffects)
  328. expect(published).toEqual([])
  329. })
  330. it('has the namespace-plugin export shape (no stray default)', () => {
  331. expect('default' in spawn).toBe(false)
  332. expect(spawn.name).toBe('subagent-spawn')
  333. expect(spawn.inject).toEqual(['subagents'])
  334. const loader = Object.create(Loader.prototype) as Loader
  335. const unwrapped = loader.unwrapExports(spawn) as Record<string, unknown>
  336. expect(unwrapped).toBe(spawn)
  337. expect(unwrapped.name).toBe('subagent-spawn')
  338. expect(unwrapped.inject).toEqual(['subagents'])
  339. expect(typeof unwrapped.apply).toBe('function')
  340. })
  341. describe('persona and toolFilter (the scoped child world)', () => {
  342. it('a per-child persona shadows the deployment persona in the child request only', async () => {
  343. const { ctx, parent, adapter } = await setup([
  344. textResponse('parent answer'),
  345. textResponse('child answer'),
  346. ])
  347. parent.send([{ type: 'text', text: 'hi' }])
  348. await parent.whenIdle()
  349. const run = await start(ctx, 'spawn', {
  350. prompt: [{ type: 'text', text: 'do X' }],
  351. parent,
  352. persona: 'You are the tersest test runner.',
  353. })
  354. await run.result
  355. const childRequest = adapter.requests.at(-1)!
  356. expect(childRequest.system).toContain('You are the tersest test runner.')
  357. // The parent's earlier request carried no such persona.
  358. expect(adapter.requests[0]!.system ?? '').not.toContain('tersest test runner')
  359. await run.dispose()
  360. })
  361. it('toolFilter hides denied tools from the child prompt AND refuses their execution', async () => {
  362. const { ctx, parent, adapter } = await setup([
  363. // The child tries the denied tool anyway, then answers.
  364. toolCallResponse('c1', 'forbidden_tool', {}),
  365. textResponse('done'),
  366. ])
  367. ctx.tools.register({
  368. name: 'forbidden_tool', description: 'global', parameters: {},
  369. execute: () => Promise.resolve([{ type: 'text', text: 'ran' }]),
  370. })
  371. const run = await start(ctx, 'spawn', {
  372. prompt: [{ type: 'text', text: 'do X' }],
  373. parent,
  374. toolFilter: { deny: ['forbidden_tool'] },
  375. })
  376. const result = await run.result
  377. expect(result.stopReason).toBe('completed')
  378. // Not advertised…
  379. const childRequest = adapter.requests[0]!
  380. expect((childRequest.tools ?? []).map(t => t.name)).not.toContain('forbidden_tool')
  381. // …and the attempted call executed as UNKNOWN_TOOL (visible in the log).
  382. const child = ctx.agents.get(run.id)!
  383. const toolResult = child.session.events.find(e => e.type === 'tool/result')!
  384. expect(JSON.stringify(toolResult.data)).toContain('unknown tool')
  385. await run.dispose()
  386. })
  387. it('an unknown toolFilter name fails the spawn loudly with no orphaned child', async () => {
  388. const { ctx, parent } = await setup([])
  389. const before = ctx.agents.list().length
  390. await expect(start(ctx, 'spawn', {
  391. prompt: [{ type: 'text', text: 'do X' }],
  392. parent,
  393. toolFilter: { deny: ['no_such_tool'] },
  394. })).rejects.toThrow(/unknown global tool "no_such_tool"/)
  395. expect(ctx.agents.list().length).toBe(before)
  396. })
  397. })
  398. it('spawning from a DISPOSING parent fails loud with no orphaned child (INACTIVE_EFFECT teaching error)', async () => {
  399. const { ctx } = await setup([])
  400. // A handle-owned parent we can dispose (config agents dispose with the loop fiber).
  401. const parentHandle = await ctx.agents.create({
  402. agentId: AgentId('doomed-parent'),
  403. sessionId: SessionId('doomed-s'),
  404. agentOptions: { model: 'mock' },
  405. })
  406. await parentHandle.dispose()
  407. const before = ctx.agents.list().length
  408. const sessionsBefore = ctx.sessions.list().length
  409. const published: string[] = []
  410. ctx.on('session/created', () => void published.push('session/created'))
  411. ctx.on('agent/created', () => void published.push('agent/created'))
  412. ctx.on('agent/session-start', () => void published.push('agent/session-start'))
  413. await expect(start(ctx, 'spawn', {
  414. prompt: [{ type: 'text', text: 'do X' }],
  415. parent: parentHandle.agent,
  416. })).rejects.toThrow(/inactive context/)
  417. expect(ctx.agents.list().length).toBe(before)
  418. expect(ctx.sessions.list()).toHaveLength(sessionsBefore)
  419. expect(published).toEqual([])
  420. })
  421. it('parent disposal during the child setup transaction prevents every publication notification', async () => {
  422. const { ctx } = await setup([])
  423. const parentHandle = await ctx.agents.create({
  424. agentId: AgentId('setup-race-parent'),
  425. sessionId: SessionId('setup-race-parent-session'),
  426. agentOptions: { model: 'mock' },
  427. })
  428. const published: string[] = []
  429. ctx.on('session/created', () => void published.push('session/created'))
  430. ctx.on('agent/created', () => void published.push('agent/created'))
  431. ctx.on('agent/session-start', () => void published.push('agent/session-start'))
  432. const starting = start(ctx, 'spawn', {
  433. prompt: [{ type: 'text', text: 'must never run' }],
  434. parent: parentHandle.agent,
  435. })
  436. // The factory has entered its awaited unpublished setup transaction. The
  437. // parent context owns that transaction, so disposal wins without an
  438. // observer ever seeing the child.
  439. await parentHandle.dispose()
  440. await expect(starting).rejects.toThrow(/owner disposed during setup|inactive context/)
  441. expect(published).toEqual([])
  442. })
  443. })