reflectdb 0.1.3 → 0.3.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.
@@ -2527,6 +2527,18 @@ class MessageHandler {
2527
2527
  storage = null;
2528
2528
  minSchemaVersion = 0;
2529
2529
  messageQueues = new Map;
2530
+ async whenIdle(clientId) {
2531
+ for (let i = 0;i < 100; i++) {
2532
+ const queue = this.messageQueues.get(clientId);
2533
+ if (!queue)
2534
+ return;
2535
+ await queue.catch(() => {
2536
+ return;
2537
+ });
2538
+ if (this.messageQueues.get(clientId) === queue)
2539
+ return;
2540
+ }
2541
+ }
2530
2542
  resultCache = new ResultCache;
2531
2543
  broadcast;
2532
2544
  ops;
@@ -769,6 +769,20 @@ declare class MessageHandler<TAuth extends AuthContext = AuthContext> {
769
769
  private storage;
770
770
  private minSchemaVersion;
771
771
  private messageQueues;
772
+ /**
773
+ * Resolves once every message queued for `clientId` has finished processing.
774
+ *
775
+ * Messages are handled on a per-client serial queue, and `onMessage` returns
776
+ * before that work settles — fine for a long-lived connection, where replies
777
+ * stream out whenever they are ready. A serverless HTTP handler has no such
778
+ * luxury: it must know when the replies to the request it is holding exist,
779
+ * or it returns an empty body and the client hangs. See the SSE transport's
780
+ * `serverless` mode.
781
+ *
782
+ * Never rejects: a failed message is the caller's concern via its own reply,
783
+ * not this barrier's.
784
+ */
785
+ whenIdle(clientId: string): Promise<void>;
772
786
  private resultCache;
773
787
  private broadcast;
774
788
  private ops;