convex 1.24.7-alpha.1 → 1.24.7

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.
@@ -28,7 +28,7 @@ var convex = (() => {
28
28
  });
29
29
 
30
30
  // src/index.ts
31
- var version = "1.24.7-alpha.1";
31
+ var version = "1.24.7";
32
32
 
33
33
  // src/values/base64.ts
34
34
  var base64_exports = {};
@@ -1536,13 +1536,43 @@ var convex = (() => {
1536
1536
  var CLOSE_GOING_AWAY = 1001;
1537
1537
  var CLOSE_NO_STATUS = 1005;
1538
1538
  var CLOSE_NOT_FOUND = 4040;
1539
+ var serverDisconnectErrors = {
1540
+ // A known error, e.g. during a restart or push
1541
+ InternalServerError: { timeout: 1e3 },
1542
+ // ErrorMetadata::overloaded() messages that we realy should back off
1543
+ SubscriptionsWorkerFullError: { timeout: 3e3 },
1544
+ TooManyConcurrentRequests: { timeout: 3e3 },
1545
+ CommitterFullError: { timeout: 3e3 },
1546
+ AwsTooManyRequestsException: { timeout: 3e3 },
1547
+ ExecuteFullError: { timeout: 3e3 },
1548
+ SystemTimeoutError: { timeout: 3e3 },
1549
+ ExpiredInQueue: { timeout: 3e3 },
1550
+ // More ErrorMetadata::overloaded() that typically indicate a deploy just happened
1551
+ VectorIndexesUnavailable: { timeout: 1e3 },
1552
+ SearchIndexesUnavailable: { timeout: 1e3 },
1553
+ // More ErrorMeatadata::overloaded()
1554
+ VectorIndexTooLarge: { timeout: 3e3 },
1555
+ SearchIndexTooLarge: { timeout: 3e3 },
1556
+ TooManyWritesInTimePeriod: { timeout: 3e3 }
1557
+ };
1558
+ function classifyDisconnectError(s) {
1559
+ if (s === void 0) return "Unknown";
1560
+ for (const prefix of Object.keys(
1561
+ serverDisconnectErrors
1562
+ )) {
1563
+ if (s.startsWith(prefix)) {
1564
+ return prefix;
1565
+ }
1566
+ }
1567
+ return "Unknown";
1568
+ }
1539
1569
  var WebSocketManager = class {
1540
1570
  socket;
1541
1571
  connectionCount;
1542
1572
  _hasEverConnected = false;
1543
1573
  lastCloseReason;
1544
1574
  /** Upon HTTPS/WSS failure, the first jittered backoff duration, in ms. */
1545
- initialBackoff;
1575
+ defaultInitialBackoff;
1546
1576
  /** We backoff exponentially, but we need to cap that--this is the jittered max. */
1547
1577
  maxBackoff;
1548
1578
  /** How many times have we failed consecutively? */
@@ -1562,7 +1592,7 @@ var convex = (() => {
1562
1592
  this.socket = { state: "disconnected" };
1563
1593
  this.connectionCount = 0;
1564
1594
  this.lastCloseReason = "InitialConnect";
1565
- this.initialBackoff = 100;
1595
+ this.defaultInitialBackoff = 1e3;
1566
1596
  this.maxBackoff = 16e3;
1567
1597
  this.retries = 0;
1568
1598
  this.serverInactivityThreshold = 3e4;
@@ -1647,15 +1677,8 @@ var convex = (() => {
1647
1677
  }
1648
1678
  this.logger.log(msg);
1649
1679
  }
1650
- if (event.reason?.includes("SubscriptionsWorkerFullError")) {
1651
- this.scheduleReconnect("SubscriptionsWorkerFullError");
1652
- } else if (event.reason?.includes("TooManyConcurrentRequests")) {
1653
- this.scheduleReconnect("TooManyConcurrentRequests");
1654
- } else if (event.reason?.includes("InternalServerError")) {
1655
- this.scheduleReconnect("InternalServerError");
1656
- } else {
1657
- this.scheduleReconnect("unknown");
1658
- }
1680
+ const reason = classifyDisconnectError(event.reason);
1681
+ this.scheduleReconnect(reason);
1659
1682
  return;
1660
1683
  };
1661
1684
  }
@@ -1909,7 +1932,7 @@ var convex = (() => {
1909
1932
  this.logger.logVerbose(message);
1910
1933
  }
1911
1934
  nextBackoff(reason) {
1912
- const initialBackoff = reason === "SubscriptionsWorkerFullError" ? 5e3 : reason === "TooManyConcurrentRequests" ? 5e3 : reason === "InternalServerError" ? 5e3 : this.initialBackoff;
1935
+ const initialBackoff = reason === "client" ? this.defaultInitialBackoff : reason === "Unknown" ? this.defaultInitialBackoff : serverDisconnectErrors[reason].timeout;
1913
1936
  const baseBackoff = initialBackoff * Math.pow(2, this.retries);
1914
1937
  this.retries += 1;
1915
1938
  const actualBackoff = Math.min(baseBackoff, this.maxBackoff);