Skip to content

Support graceful whole-server shutdown through CDP Browser.close #680

Description

@zhouzirui-2026

Problem

moli serve currently has no client-controlled graceful whole-server shutdown path through CDP. Browser.close is not present in BrowserAction, so the Cairn dedicated-browser adapter waits for the command, times out, and terminates its owned child process. That now recovers safely with #679, but it still skips orderly owner/checkpoint/profile teardown and reports graceful=false.

A persistent-profile synthetic lifecycle built from merged #677 plus #679 can reopen after forced termination, but abnormal termination should remain fallback, not the normal controller contract.

Desired behavior

A valid Browser.close sent on the browser-level CDP websocket should:

  1. produce the normal empty success response;
  2. flush that response to the requesting frontend;
  3. stop accepting new protocol connections;
  4. shut down all CDP owners/target frontends and join checkpoint workers;
  5. return from ProtocolServer::serve() so profile/storage guards drop normally;
  6. exit moli serve with status 0.

Target/page websocket clients must not gain process-shutdown authority merely by sending a Browser-domain string. Invalid params/session routing should fail without shutting the server down. Repeated close requests should be idempotent.

Acceptance

  • protocol test observes the Browser.close success before websocket close;
  • open page/target sockets close and owner registry drains;
  • a profiled server exits cleanly, releases the profile lock, and the same profile immediately reopens;
  • localStorage/cookie checkpoint written before close remains available after restart;
  • no sleep-based shutdown race or unbounded output buffering;
  • forced process termination remains a supervisor fallback, not the passing graceful path.

I am preparing a focused implementation/probe. This is independent from #666/#677 directory durability and #678/#679 abnormal-owner lock recovery.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions