@ai-sdk/mcp 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1273,7 +1273,7 @@ var HttpMCPTransport = class {
1273
1273
  });
1274
1274
  }
1275
1275
  this.abortController = new AbortController();
1276
- void this.openInboundSse();
1276
+ this.startInboundSse();
1277
1277
  }
1278
1278
  async close() {
1279
1279
  var _a3, _b3, _c;
@@ -1330,7 +1330,7 @@ var HttpMCPTransport = class {
1330
1330
  }
1331
1331
  if (response.status === 202) {
1332
1332
  if (!this.inboundSseConnection) {
1333
- void this.openInboundSse();
1333
+ this.startInboundSse();
1334
1334
  }
1335
1335
  return;
1336
1336
  }
@@ -1390,7 +1390,13 @@ var HttpMCPTransport = class {
1390
1390
  (_c2 = this.onerror) == null ? void 0 : _c2.call(this, error2);
1391
1391
  }
1392
1392
  };
1393
- processEvents();
1393
+ void processEvents().catch((error2) => {
1394
+ var _a4;
1395
+ if (error2 instanceof Error && error2.name === "AbortError") {
1396
+ return;
1397
+ }
1398
+ (_a4 = this.onerror) == null ? void 0 : _a4.call(this, error2);
1399
+ });
1394
1400
  return;
1395
1401
  }
1396
1402
  const error = new MCPClientError({
@@ -1430,12 +1436,21 @@ var HttpMCPTransport = class {
1430
1436
  }
1431
1437
  const delay = this.getNextReconnectionDelay(this.inboundReconnectAttempts);
1432
1438
  this.inboundReconnectAttempts += 1;
1433
- setTimeout(async () => {
1439
+ setTimeout(() => {
1434
1440
  var _a4;
1435
1441
  if ((_a4 = this.abortController) == null ? void 0 : _a4.signal.aborted) return;
1436
- await this.openInboundSse(false, this.lastInboundEventId);
1442
+ this.startInboundSse(false, this.lastInboundEventId);
1437
1443
  }, delay);
1438
1444
  }
1445
+ startInboundSse(triedAuth = false, resumeToken) {
1446
+ void this.openInboundSse(triedAuth, resumeToken).catch((error) => {
1447
+ var _a3;
1448
+ if (error instanceof Error && error.name === "AbortError") {
1449
+ return;
1450
+ }
1451
+ (_a3 = this.onerror) == null ? void 0 : _a3.call(this, error);
1452
+ });
1453
+ }
1439
1454
  // Open optional inbound SSE stream; best-effort and resumable
1440
1455
  async openInboundSse(triedAuth = false, resumeToken) {
1441
1456
  var _a3, _b3, _c, _d, _e, _f;
@@ -1519,10 +1534,27 @@ var HttpMCPTransport = class {
1519
1534
  }
1520
1535
  };
1521
1536
  this.inboundSseConnection = {
1522
- close: () => reader.cancel()
1537
+ close: () => {
1538
+ void reader.cancel().catch((error) => {
1539
+ var _a4;
1540
+ if (error instanceof Error && error.name === "AbortError") {
1541
+ return;
1542
+ }
1543
+ (_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
1544
+ });
1545
+ }
1523
1546
  };
1524
1547
  this.inboundReconnectAttempts = 0;
1525
- processEvents();
1548
+ void processEvents().catch((error) => {
1549
+ var _a4, _b4;
1550
+ if (error instanceof Error && error.name === "AbortError") {
1551
+ return;
1552
+ }
1553
+ (_a4 = this.onerror) == null ? void 0 : _a4.call(this, error);
1554
+ if (!((_b4 = this.abortController) == null ? void 0 : _b4.signal.aborted)) {
1555
+ this.scheduleInboundSseReconnection();
1556
+ }
1557
+ });
1526
1558
  } catch (error) {
1527
1559
  if (error instanceof Error && error.name === "AbortError") {
1528
1560
  return;