Report errors when start() is called multiple times
This commit is contained in:
parent
83a43fda1e
commit
7b718de77c
3 changed files with 29 additions and 1 deletions
|
|
@ -22,6 +22,12 @@ export class SSEClientTransport implements Transport {
|
|||
}
|
||||
|
||||
start(): Promise<void> {
|
||||
if (this._eventSource) {
|
||||
throw new Error(
|
||||
"SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.",
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this._eventSource = new EventSource(this._url.href);
|
||||
this._abortController = new AbortController();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,12 @@ export class StdioClientTransport implements Transport {
|
|||
* Starts the server process and prepares to communicate with it.
|
||||
*/
|
||||
async start(): Promise<void> {
|
||||
if (this._process) {
|
||||
throw new Error(
|
||||
"StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.",
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this._process = spawn(
|
||||
this._serverParams.command,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ export class WebSocketClientTransport implements Transport {
|
|||
}
|
||||
|
||||
start(): Promise<void> {
|
||||
if (this._socket) {
|
||||
throw new Error(
|
||||
"WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.",
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this._socket = new WebSocket(this._url, SUBPROTOCOL);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue