convex 1.24.5 → 1.24.7-alpha.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +6 -4
  2. package/dist/browser.bundle.js +14 -7
  3. package/dist/browser.bundle.js.map +2 -2
  4. package/dist/cjs/browser/sync/web_socket_manager.js +13 -6
  5. package/dist/cjs/browser/sync/web_socket_manager.js.map +2 -2
  6. package/dist/cjs/cli/lib/deployApi/types.js +3 -3
  7. package/dist/cjs/cli/lib/deployApi/types.js.map +2 -2
  8. package/dist/cjs/index.js +1 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs-types/browser/sync/web_socket_manager.d.ts.map +1 -1
  11. package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +33 -33
  12. package/dist/cjs-types/cli/lib/deployApi/types.d.ts +19 -19
  13. package/dist/cjs-types/cli/lib/deployApi/types.d.ts.map +1 -1
  14. package/dist/cjs-types/index.d.ts +1 -1
  15. package/dist/cjs-types/index.d.ts.map +1 -1
  16. package/dist/cli.bundle.cjs +18 -10
  17. package/dist/cli.bundle.cjs.map +3 -3
  18. package/dist/esm/browser/sync/web_socket_manager.js +13 -6
  19. package/dist/esm/browser/sync/web_socket_manager.js.map +2 -2
  20. package/dist/esm/cli/lib/deployApi/types.js +3 -3
  21. package/dist/esm/cli/lib/deployApi/types.js.map +2 -2
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm-types/browser/sync/web_socket_manager.d.ts.map +1 -1
  25. package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +33 -33
  26. package/dist/esm-types/cli/lib/deployApi/types.d.ts +19 -19
  27. package/dist/esm-types/cli/lib/deployApi/types.d.ts.map +1 -1
  28. package/dist/esm-types/index.d.ts +1 -1
  29. package/dist/esm-types/index.d.ts.map +1 -1
  30. package/dist/react.bundle.js +14 -7
  31. package/dist/react.bundle.js.map +2 -2
  32. package/package.json +1 -1
  33. package/src/browser/sync/web_socket_manager.ts +30 -6
  34. package/src/cli/lib/deployApi/types.ts +15 -10
  35. package/src/index.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "convex",
3
3
  "description": "Client for the Convex Cloud",
4
- "version": "1.24.5",
4
+ "version": "1.24.7-alpha.0",
5
5
  "author": "Convex, Inc. <no-reply@convex.dev>",
6
6
  "homepage": "https://convex.dev",
7
7
  "repository": {
@@ -253,7 +253,13 @@ export class WebSocketManager {
253
253
  }
254
254
  this.logger.log(msg);
255
255
  }
256
- this.scheduleReconnect();
256
+ if (event.reason?.includes("SubscriptionsWorkerFullError")) {
257
+ this.scheduleReconnect("SubscriptionsWorkerFullError");
258
+ } else if (event.reason?.includes("TooManyConcurrentRequests")) {
259
+ this.scheduleReconnect("TooManyConcurrentRequests");
260
+ } else {
261
+ this.scheduleReconnect("unknown");
262
+ }
257
263
  return;
258
264
  };
259
265
  }
@@ -320,9 +326,15 @@ export class WebSocketManager {
320
326
  }, this.serverInactivityThreshold);
321
327
  }
322
328
 
323
- private scheduleReconnect() {
329
+ private scheduleReconnect(
330
+ reason:
331
+ | "client"
332
+ | "unknown"
333
+ | "SubscriptionsWorkerFullError"
334
+ | "TooManyConcurrentRequests",
335
+ ) {
324
336
  this.socket = { state: "disconnected" };
325
- const backoff = this.nextBackoff();
337
+ const backoff = this.nextBackoff(reason);
326
338
  this.logger.log(`Attempting reconnect in ${backoff}ms`);
327
339
  setTimeout(() => this.connect(), backoff);
328
340
  }
@@ -345,7 +357,7 @@ export class WebSocketManager {
345
357
  this.lastCloseReason = closeReason;
346
358
  // Close the old socket asynchronously, we'll open a new socket in reconnect.
347
359
  void this.close();
348
- this.scheduleReconnect();
360
+ this.scheduleReconnect("client");
349
361
  return;
350
362
  }
351
363
  default: {
@@ -543,8 +555,20 @@ export class WebSocketManager {
543
555
  this.logger.logVerbose(message);
544
556
  }
545
557
 
546
- private nextBackoff(): number {
547
- const baseBackoff = this.initialBackoff * Math.pow(2, this.retries);
558
+ private nextBackoff(
559
+ reason:
560
+ | "client"
561
+ | "unknown"
562
+ | "SubscriptionsWorkerFullError"
563
+ | "TooManyConcurrentRequests",
564
+ ): number {
565
+ const initialBackoff =
566
+ reason === "SubscriptionsWorkerFullError"
567
+ ? 3000
568
+ : reason === "TooManyConcurrentRequests"
569
+ ? 3000
570
+ : this.initialBackoff;
571
+ const baseBackoff = initialBackoff * Math.pow(2, this.retries);
548
572
  this.retries += 1;
549
573
  const actualBackoff = Math.min(baseBackoff, this.maxBackoff);
550
574
  const jitter = actualBackoff * (Math.random() - 0.5);
@@ -3,23 +3,28 @@ import { z } from "zod";
3
3
  export const reference = z.string();
4
4
  export type Reference = z.infer<typeof reference>;
5
5
 
6
- // passthrough for backward compat, auth was passthrough before custom JWTs were added
6
+ // These validators parse the response from the backend so although
7
+ // they roughly correspond with convex/auth.config.ts providers they
8
+ // have been processed.
9
+
10
+ // Passthrough so old CLIs can operate on new backend formats.
7
11
  const Oidc = z
8
12
  .object({
9
13
  applicationID: z.string(),
10
14
  domain: z.string(),
11
15
  })
12
16
  .passthrough();
17
+ const CustomJwt = z
18
+ .object({
19
+ type: z.literal("customJwt"),
20
+ applicationID: z.string().nullable(),
21
+ issuer: z.string(),
22
+ jwks: z.string(),
23
+ algorithm: z.string(),
24
+ })
25
+ .passthrough();
13
26
 
14
- const CustomJwt = z.object({
15
- type: z.literal("customJwt"),
16
- applicationID: z.optional(z.string()),
17
- issuer: z.string(),
18
- jwks: z.string(),
19
- algorithm: z.string(),
20
- });
21
-
22
- export const authInfo = z.union([Oidc, CustomJwt]);
27
+ export const authInfo = z.union([CustomJwt, Oidc]);
23
28
 
24
29
  export type AuthInfo = z.infer<typeof authInfo>;
25
30
 
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.24.5";
1
+ export const version = "1.24.7-alpha.0";