Skip to content

Commit ce15cd8

Browse files
authored
fix(core): report removed running shells as killed (#56982)
1 parent 815de99 commit ce15cd8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎packages/core/src/shell.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ const layer = () =>
174174
// Unblock any wait still pending when the command is removed before it terminated.
175175
yield* Deferred.fail(command.done, new NotFoundError({ id }))
176176
yield* Effect.promise(() => unlink(command.file).catch(() => {}))
177+
// Every shell reports exactly one exit; removing a running one ends it as killed.
178+
if (command.info.status === "running") yield* bus.publish(Shell.Event.Exited, { id, status: "killed" })
177179
yield* bus.publish(Shell.Event.Deleted, { id })
178180
})
179181

@@ -407,6 +409,8 @@ const layer = () =>
407409
// Report the terminal status only once captured output is complete, so a reader that
408410
// sees it never reads a partial file.
409411
yield* outputDone.await
412+
// A removed command already failed its waiters and published its exit and deletion.
413+
if (commands.get(id) !== command) return
410414
command.info = produce(command.info, (draft) => {
411415
draft.status = outcome.status
412416
if (outcome.exit !== undefined) draft.exit = outcome.exit

0 commit comments

Comments
 (0)