Skip to content

test(dxt): pin the server/discover probe answer before initialize - #271

Merged
docdyhr merged 3 commits into
mainfrom
test/dxt-discover-probe
Oct 9, 2026
Merged

docdyhr merged 3 commits into
mainfrom
test/dxt-discover-probe

Conversation

@docdyhr

@docdyhr docdyhr commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Pull Request

Description

P1 in the v4.0.9 re-test results: Claude Desktop logged Couldn't start for Cowork and Code sessions … the connection closed during the server/discover probe. The note asked whether the server exits or closes stdio on an unknown server/discover request sent before initialize.

It doesn't. The built dist/dxt-entry.js answers with JSON-RPC -32601 Method not found, stays up, and then completes initialize → tools/list (71 tools). In the Claude log, the error appears only during the 23:09Z reinstall burst on 2026-10-08. Every start since 23:10Z completes the probe (Era probe verdict: legacy without "sibling did not complete the exchange"), including this morning's at 09:16Z. No code change is needed, so this PR only adds a test to keep it that way.

Type of Change

  • 🧪 Test improvements

Changes Made

  • New tests/bin/dxt-discover-probe.test.js:
    • spawns dist/dxt-entry.js with the same isolation as mcp-wordpress-entry.test.js: a real copy of dist/ and a sandbox HOME, so no real config is read;
    • sends server/discover, expects -32601, then initialize and tools/list, and expects the process to still be running;
    • if the process exits, pending requests are rejected at once with the exit code instead of waiting for a timeout.

Testing

  • Passes (≈0.5 s). The test was green on its first run, so I mutation-checked it: with the built entry changed to exit on server/discover, it fails with server exited with code 0 in 0.4 s. I then rebuilt dist/ clean.
  • Combined run with the other three branches from this pass: 93 files / 2740 tests, lint, typecheck, format:check, security:scan

Notes for reviewers

  • test: does not cut a release.

Security

  • No sensitive information committed; the test uses dummy single-site credentials and never contacts a site

Independent review follow-up

  • No longer pins -32601: it requires an answer to the probe (a result, or Method not found), so an SDK that implements server/discover won't break it.
  • The child runs without NODE_ENV=test/CI, like the installed extension (those switch off the multi-site guard).
  • Liveness is checked with ping; exit failures report code, signal and the server's stderr; stdout is decoded as UTF-8; the child is awaited on cleanup. Mutation-checked again (fails in 0.4 s with the server's stderr).

🤖 Generated with Claude Code

Summary by Sourcery

Tests:

  • Add an end-to-end test that verifies the DXT server responds to a pre-initialize server/discover probe, remains running, and completes the normal initialization and tool-listing handshake.

Claude Desktop sends server/discover before initialize. If the server
exited or closed stdio on that unknown method, the host would log
"Couldn't start for Cowork and Code sessions ... the connection closed
during the server/discover probe". The built dxt-entry.js answers
-32601 Method not found and stays up; this test spawns it in a sandbox
and keeps it that way (checked by making it exit on the probe: the test
fails with "server exited with code 0").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:52
@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sorry @docdyhr, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds an isolated process-level regression test pinning the server’s behavior for a pre-initialize server/discover request: it must return Method not found, stay running, and complete the normal initialization and tool-list handshake.

File-Level Changes

Change Details Files
Add an end-to-end regression test that verifies the DXT entrypoint tolerates Claude Desktop’s pre-initialize discovery probe.
  • Run the built entrypoint from an isolated copied dist directory with sandboxed configuration and dummy credentials.
  • Send server/discover before initialization and assert a JSON-RPC -32601 Method not found response.
  • Continue with initialize and tools/list, asserting the process remains alive and the handshake succeeds.
  • Reject pending requests immediately when the child exits to avoid masking failures behind request timeouts.
tests/bin/dxt-discover-probe.test.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T09:54:12.512551Z d8132c0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

docdyhr and others added 2 commits October 9, 2026 13:48
Review follow-up:
- The test pinned -32601, which is only the SDK's generic answer while
  it has no server/discover handler; a later SDK that implements the
  method would have failed it while helping the host. It now requires
  an answer to id 1: a result, or "Method not found".
- NODE_ENV=test (set by Vitest) and CI switch off the multi-site
  fail-closed guard; the child now runs without them, like the
  installed extension.
- Liveness is checked with a ping after tools/list instead of
  child.exitCode (null until the exit event is processed).
- Exit failures name the code, signal and the server's last stderr;
  stdin EPIPE is ignored; stdout is decoded as UTF-8; the child is
  awaited on cleanup.

Checked by making the built entry exit on the probe: fails in 0.4 s
with "server exited (code 3 ...)" and the server's stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@docdyhr
docdyhr enabled auto-merge (squash) October 9, 2026 12:47
@docdyhr
docdyhr disabled auto-merge October 9, 2026 13:19
@docdyhr
docdyhr merged commit 1e204ba into main Oct 9, 2026
24 checks passed
@docdyhr
docdyhr deleted the test/dxt-discover-probe branch October 9, 2026 13:19
@docdyhr

docdyhr commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 4.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants