verify automation interruption recovery and manual debug lifecycle
This commit is contained in:
@@ -141,11 +141,23 @@ final class HeadlessProcessSession implements HeadlessGateway.Session {
|
||||
var target = advance.get();
|
||||
if (target == null || target.result.isDone() || !target.cancelled.compareAndSet(false, true) || dead.get()) return;
|
||||
var cancel = new Pending("cancel", null, null);
|
||||
send(cancel, mapper.createObjectNode().put("targetRequestId", target.id));
|
||||
timer.schedule(() -> { if (!target.result.isDone() || !cancel.result.isDone()) abort("Runtime did not stop after cancellation"); }, limits.shutdownTimeoutMs(), TimeUnit.MILLISECONDS);
|
||||
try {
|
||||
send(cancel, mapper.createObjectNode().put("targetRequestId", target.id));
|
||||
timer.schedule(() -> { if (!target.result.isDone() || !cancel.result.isDone()) abort("Runtime did not stop after cancellation"); }, limits.shutdownTimeoutMs(), TimeUnit.MILLISECONDS);
|
||||
} catch (RuntimeException lost) {
|
||||
// A concurrent crash may close the writer/timer. Fail the pending operation,
|
||||
// but do not prevent the authority owner from awaiting shutdown and cleanup.
|
||||
abort("Headless session lost during cancellation");
|
||||
}
|
||||
}
|
||||
@Override public synchronized CompletionStage<Void> shutdown() {
|
||||
if (shutdown != null) return shutdown;
|
||||
if (shutdown != null) {
|
||||
// The first forced shutdown reports infrastructure failure. An explicit human
|
||||
// retry may acknowledge completed cleanup, but never releases a living process.
|
||||
if (shutdown.isCompletedExceptionally() && dead.get() && !alive())
|
||||
shutdown = CompletableFuture.completedFuture(null);
|
||||
return shutdown;
|
||||
}
|
||||
closing = true;
|
||||
shutdown = CompletableFuture.runAsync(() -> {
|
||||
long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(limits.shutdownTimeoutMs());
|
||||
|
||||
Reference in New Issue
Block a user