Repository navigation
Conversation
`server_start` and `daily_active` are now sent with `sendClearcutBatch` from the server process instead of through the watchdog. The session id is generated in `ClearcutLogger` and passed to the watchdog with `--session-id`, so watchdog events keep the same `session_id`.
The watchdog sends `server_shutdown` when the server exits. If no watchdog was started, `ClearcutLogger.logServerShutdownIfNoWatchdog()` sends it from the server process during shutdown, with a 2.5 s request timeout. After this call, the logger never starts a watchdog.
yulunz
force-pushed
the
perf/telemetry-lazy-watchdog
branch
from
November 17, 2026 20:13
8170701 to
014f1ae
Compare
Collaborator
Author
|
Dropping: not logging server_shutdown for idle sessions is acceptable; see #3427. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3427
Part 4 of 4, stacked on #3513. Should land together with #3513.
Summary
The watchdog sends
server_shutdownwhen the server exits. Since theprevious change, the watchdog starts only on the first tool call or server
error, so idle sessions sent no
server_shutdown. This change addsClearcutLogger.logServerShutdownIfNoWatchdog():server_shutdownafter the parent exits.{server_shutdown: {}}withsession_id,app_version, andos_typethroughsendClearcutBatch. This is the sameshape as the watchdog's
sendShutdownEvent(), so there is nomcp_client. The request timeout is 2.5 s (SHUTDOWN_REQUEST_TIMEOUT_MS,declared once in
ClearcutLogger.ts). The method never throws.#shutDownflag. After that,#getWatchdog()never spawns awatchdog. Events that need one, such as a tool call that finishes during
shutdown, are dropped and logged. This prevents a second
server_shutdown. A droppedtool_activeevent does not updatelastToolCall.sendClearcutBatch()takes a new optionalrequestTimeoutMs. The default isstill 30 s.
Callers:
shutdown()insrc/bin/chrome-devtools-mcp-main.tsstarts the call,awaits
server.close(), then awaits the call. Both run concurrentlywithin the existing 5 s backstop, and a
server.close()error behaves asbefore.
cleanup()insrc/daemon/daemon.tsdoes the same aroundmcpServer?.close().User-visible behavior changes
send
server_shutdownagain. The server process sends it, without theX-Watchdog-Pidheader.is running. It stays within the existing 5 s backstop.
server_shutdown. Onlya watchdog can report that, and none is running.
Test plan
tests/telemetry/ClearcutLogger.test.ts:sendClearcutBatchis called once with the exactshutdown event and
{clearcutEndpoint, requestTimeoutMs: 2500}, and thefactory is not called.
sendClearcutBatchis not called, and the methoddoes not call
watchdog.send.logToolInvocation()does not call the watchdog factory.tests/telemetry/watchdog/ClearcutSender.test.ts:sendClearcutBatchaborts at
requestTimeoutMs.tests/e2e/telemetry.test.ts: new idle case (Linux/macOS) where SIGTERMdelivers
server_shutdownwith thesession_idofserver_startandwithout
X-Watchdog-Pid. SIGKILL, SIGTERM, and process-group coveragestays on the after-tool-call path, where the watchdog sends
server_shutdown.npm run test: 2029 tests, 2027 pass, 2 skipped (Windows-only),0 fail.
npm run format: clean.