Report errors when start() is called multiple times

This commit is contained in:
Justin Spahr-Summers 2024-10-16 13:14:47 +01:00
commit 7b718de77c
No known key found for this signature in database

View file

@ -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();