mcp-stdio-transport.test.ts 816 B

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from "vitest";
  2. import { ProcessTreeStdioClientTransport } from "../src/mcp/stdio-transport.js";
  3. describe("ProcessTreeStdioClientTransport", () => {
  4. it("retains the direct child exit code for crash telemetry", async () => {
  5. const transport = new ProcessTreeStdioClientTransport({
  6. args: ["-e", "process.exit(7)"],
  7. command: process.execPath,
  8. stderr: "ignore",
  9. });
  10. const closed = new Promise<void>((resolve) => {
  11. transport.onclose = resolve;
  12. });
  13. await transport.start();
  14. await closed;
  15. expect(transport.processExit).toMatchObject({
  16. exitCode: 7,
  17. signal: null,
  18. });
  19. expect(transport.processExit?.exitedAt).toBeGreaterThanOrEqual(
  20. transport.processExit?.startedAt ?? Number.POSITIVE_INFINITY,
  21. );
  22. });
  23. });