test(desktop): cover a handle left open after Host teardown

Drive the built Host through the update handoff with a handle opened on
shutdown, and state why the exit skips startup failures.
This commit is contained in:
Turtle committed 2026-10-18 14:58:17 +08:00
1 parent 6252a29a20
commit 23fb3eadd1
2 files changed
+7 -1

No files matched your search

+2 -1
View File
@@ -55,7 +55,8 @@ async function main(): Promise<void> {
await running?.shutdown.shutdown(0)
await send({ type: 'shutdown-complete' })
if (process.connected) process.disconnect()
// The application tree is disposed; a handle it left open must not delay the update handoff deadline.
// A handle a disposed plugin left open would otherwise keep the Host alive past the shell's graceful
// deadline; a startup failure keeps its own diagnostic exit.
if (running !== undefined) process.exit()
})()
process.on('message', (message: unknown) => {
+5
View File
@@ -184,6 +184,11 @@ describe.skipIf(!existsSync(builtHost))('built Desktop welcome flow', () => {
await backend!.account.cancel(waiting.attempt!.id)
expect((await fetch(late, { redirect: 'manual' })).status).not.toBe(302)
expect(await status()).toMatchObject({ loggedIn: false })
// A handle left open after acknowledged teardown must not fail the update handoff.
vi.stubEnv('NODE_OPTIONS', `--import=data:text/javascript,${encodeURIComponent(
"process.on('message', message => { if (message?.type === 'shutdown') setInterval(() => {}, 1000) })")}`)
await restart()
await host!.stop(true)
} finally {
await host?.stop()
await platform.close()