Jelajahi Sumber

test(mcp-client): preserve startup error cause

Strict startup intentionally wraps connection and synchronization failures with the server-qualified activation diagnostic while retaining the original error in Error.cause. The prior assertion checked only the wrapper text, so the causal chain could regress unnoticed and erase the actionable transport failure.

Assert the full wrapper message and object identity of the original connection error in cause. This keeps operator-facing context and the underlying SDK diagnostic independently stable without changing production behavior.
Tianyi Cui 2 bulan lalu
induk
melakukan
0e01036a2a
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      packages/mcp/mcp-client/tests/apply.spec.ts

+ 6 - 2
packages/mcp/mcp-client/tests/apply.spec.ts

@@ -254,11 +254,15 @@ describe('apply (plugin lifecycle)', () => {
   })
 
   it('rejects activation and still closes the client when startup failure is configured as fatal', async () => {
-    mockConnect.mockRejectedValue(new Error('connection refused'))
+    const cause = new Error('connection refused')
+    mockConnect.mockRejectedValue(cause)
     await expect(apply(ctx, {
       ...stdioConfig,
       failOnStartupError: true,
-    })).rejects.toThrow('initial connection or tool synchronization failed')
+    })).rejects.toMatchObject({
+      message: 'mcp-client(srv): initial connection or tool synchronization failed',
+      cause,
+    })
 
     expect(mockListTools).not.toHaveBeenCalled()
     expect(ctx.tools.get('mcp__srv__remote')).toBeUndefined()