Skip to content

Commit d154914

Browse files
rootroot
authored andcommitted
fix: change pid return type from undefined to be null
1 parent 7e134f2 commit d154914

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/client/stdio.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test("should return child process pid", async () => {
6464
const client = new StdioClientTransport(serverParameters);
6565

6666
await client.start();
67-
expect(client.pid).toBeDefined();
67+
expect(client.pid).not.toBeNull();
6868
await client.close();
69-
expect(client.pid).toBeUndefined();
69+
expect(client.pid).toBeNull();
7070
});

src/client/stdio.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,13 @@ export class StdioClientTransport implements Transport {
184184
return this._process?.stderr ?? null;
185185
}
186186

187-
get pid(): number | undefined {
188-
return this._process?.pid;
187+
/**
188+
* The child process pid spawned by this transport.
189+
*
190+
* This is only available after the transport has been started.
191+
*/
192+
get pid(): number | null {
193+
return this._process?.pid ?? null;
189194
}
190195

191196
private processReadBuffer() {

0 commit comments

Comments
 (0)