Skip to content

Commit 4917a3c

Browse files
fix(client/streamableHttp): retry sendMessage on 401
After receiving a 401, attempt to `auth`. Whether the authorization works immediately or causes a redirect, retry sending the message.
1 parent 7e18c70 commit 4917a3c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/client/streamableHttp.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ export class StreamableHTTPClientTransport implements Transport {
401401

402402
if (!response.ok) {
403403
if (response.status === 401 && this._authProvider) {
404-
const result = await auth(this._authProvider, { serverUrl: this._url });
405-
if (result !== "AUTHORIZED") {
406-
throw new UnauthorizedError();
407-
}
404+
// Whether this is REDIRECT or AUTHORIZED, retry sending the message.
405+
await auth(this._authProvider, { serverUrl: this._url });
408406

409407
// Purposely _not_ awaited, so we don't call onerror twice
410408
return this.send(message);

0 commit comments

Comments
 (0)