refactor(runtime): remove duplicate terminal ownership state
This commit is contained in:
@@ -58,19 +58,18 @@ export class LocalTerminalHandle implements SubprocessTerminalHandle {
|
||||
exitCode: exitSignal === undefined || exitSignal === 0 ? exitCode : null,
|
||||
signal: signalName(exitSignal),
|
||||
})
|
||||
void this.terminate().catch(() => {})
|
||||
})
|
||||
}
|
||||
|
||||
// node-pty writes synchronously; the seam returns a promise for remote transports.
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
// oxlint-disable-next-line typescript/require-await -- Preserve promise rejection semantics at the async provider seam.
|
||||
async write(data: string): Promise<void> {
|
||||
if (this.exited) throw new Error('terminal process has exited')
|
||||
this.terminal.write(data)
|
||||
}
|
||||
|
||||
// Local inspection is synchronous; the seam returns a promise for remote transports.
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
// oxlint-disable-next-line typescript/require-await -- Preserve promise rejection semantics at the async provider seam.
|
||||
async inspectForeground(): Promise<SubprocessTerminalForeground | undefined> {
|
||||
this.descendants()
|
||||
const processGroupId = this.inspector.foregroundPgid(this.pid)
|
||||
|
||||
@@ -128,6 +128,7 @@ describe('LocalTerminalHandle', () => {
|
||||
const handle = new LocalTerminalHandle(pty.asPty(), inspector, 20)
|
||||
|
||||
const quiescent = handle.terminate()
|
||||
expect(handle.terminate()).toBe(quiescent)
|
||||
await vi.advanceTimersByTimeAsync(20)
|
||||
expect(inspector.processes).toContainEqual([124, 'SIGKILL'])
|
||||
expect(pty.kills).toEqual([])
|
||||
|
||||
Reference in New Issue
Block a user