querysub 0.506.0 → 0.508.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.506.0",
3
+ "version": "0.508.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -247,9 +247,9 @@ class PathWatcher {
247
247
  obj.watchers.delete(callback);
248
248
 
249
249
  if (isOwnNodeId(callback)) {
250
- auditLog("local UNWATCH PARENT", { path, network: decodeParentFilter(path)?.network || DEFAULT_NETWORK, reason });
250
+ auditLog("local UNWATCH PARENT", { path, network: decodeParentFilter(path)?.network || DEFAULT_NETWORK, reason, remainingWatchers: obj.watchers.size });
251
251
  } else {
252
- auditLog("non-local UNWATCH PARENT", { path, network: decodeParentFilter(path)?.network || DEFAULT_NETWORK, watcher: callback, remoteNodeId: debugNodeId(callback), remoteNodeThreadId: debugNodeThread(callback), reason });
252
+ auditLog("non-local UNWATCH PARENT", { path, network: decodeParentFilter(path)?.network || DEFAULT_NETWORK, watcher: callback, remoteNodeId: debugNodeId(callback), remoteNodeThreadId: debugNodeThread(callback), reason, remainingWatchers: obj.watchers.size });
253
253
  }
254
254
 
255
255
  if (obj.watchers.size === 0) {
@@ -582,8 +582,6 @@ class AuthorityPathValueStorage {
582
582
  // NOTE: I don't think we have to handle the case where we are the authority,
583
583
  // because we don't delete any actual data here.
584
584
  this.parentsSynced.delete(path);
585
- let decoded = decodeParentFilter(path);
586
- this.parentsSynced.delete(this.parentSyncKey(hack_stripPackedPath(path), decoded?.network));
587
585
  }
588
586
 
589
587
  /** Used for atomic operations, to ensure a path is stable enough (and to check that it hasn't
@@ -610,10 +608,6 @@ class AuthorityPathValueStorage {
610
608
  }
611
609
  return true;
612
610
  }
613
- private parentSyncKey(strippedParentPath: string, network: string | undefined): string {
614
- if (!network || network === DEFAULT_NETWORK) return strippedParentPath;
615
- return strippedParentPath + String.fromCharCode(1) + "network=" + network;
616
- }
617
611
 
618
612
  public isSynced(path: string) {
619
613
  if (PathRouter.isSelfAuthority(path)) return true;
@@ -643,7 +637,7 @@ class AuthorityPathValueStorage {
643
637
  let remoteWatchRoute = remoteWatcher.getRemoteParentWatchRoute(path);
644
638
  if (remoteWatchRoute !== undefined) {
645
639
  let parent = getParentPathStr(path);
646
- let ranges = this.parentsSynced.get(this.parentSyncKey(parent, getPathNetwork(path)));
640
+ let ranges = this.parentsSynced.get(parent);
647
641
  // NOTE: We can't cache this because when we stop watching the parent, the remote watch will remove it, which will cause us to be no longer synced. However, it's not going to know to go into our synced cache and remove it.
648
642
  if (ranges === true) return true;
649
643
  if (ranges) {
@@ -665,7 +659,7 @@ class AuthorityPathValueStorage {
665
659
  parentPath = hack_stripPackedPath(parentPath);
666
660
  if (PathRouter.isLocalPath(parentPath)) return true;
667
661
 
668
- let synced = this.parentsSynced.get(originalPath) || this.parentsSynced.get(this.parentSyncKey(parentPath, range?.network));
662
+ let synced = this.parentsSynced.get(originalPath) || this.parentsSynced.get(parentPath);
669
663
  if (synced === true) return true;
670
664
  // See if the ranges received so far cover the requested range. If we only request a partial range, then this will always be the case. We'll never fully synchronize the path.
671
665
  if (synced && range) {
@@ -707,7 +701,7 @@ class AuthorityPathValueStorage {
707
701
 
708
702
  let decoded = decodeParentFilter(obj.parentPath);
709
703
  let range = decoded ? { start: decoded.start, end: decoded.end } : { start: 0, end: 1 };
710
- let parentPath = this.parentSyncKey(hack_stripPackedPath(obj.parentPath), decoded?.network);
704
+ let parentPath = hack_stripPackedPath(obj.parentPath);
711
705
 
712
706
  let prevSynced = this.parentsSynced.get(parentPath);
713
707
  if (prevSynced === true) continue;
@@ -1,4 +1,4 @@
1
- import { delay, runInfinitePoll } from "socket-function/src/batching";
1
+ import { batchFunction, delay, runInfinitePoll } from "socket-function/src/batching";
2
2
  import { cache } from "socket-function/src/caching";
3
3
  import { blue, magenta, yellow } from "socket-function/src/formatting/logColors";
4
4
  import { timeInHour, timeInSecond } from "socket-function/src/misc";
@@ -492,20 +492,16 @@ export class PathFunctionRunner {
492
492
  );
493
493
  };
494
494
 
495
- private pendingTickWaiters: { runAtTime: Time; resolve: () => void; }[] | undefined;
496
- private async letIOClear(runAtTime: Time): Promise<void> {
497
- if (!this.pendingTickWaiters) {
498
- let waiters: { runAtTime: Time; resolve: () => void; }[] = [];
499
- this.pendingTickWaiters = waiters;
500
- void delay(100).then(() => {
501
- this.pendingTickWaiters = undefined;
502
- waiters.sort((a, b) => compareTime(a.runAtTime, b.runAtTime));
503
- for (let w of waiters) w.resolve();
504
- });
495
+ private letIOClearBatch = batchFunction(
496
+ { delay: 1, throttleWindow: 5000 },
497
+ (waiters: { runAtTime: Time; resolve: () => void; }[]) => {
498
+ waiters.sort((a, b) => compareTime(a.runAtTime, b.runAtTime));
499
+ for (let w of waiters) w.resolve();
505
500
  }
506
- let waiters = this.pendingTickWaiters;
501
+ );
502
+ private async letIOClear(runAtTime: Time): Promise<void> {
507
503
  await new Promise<void>(resolve => {
508
- waiters.push({ runAtTime, resolve });
504
+ void this.letIOClearBatch({ runAtTime, resolve });
509
505
  });
510
506
  }
511
507
 
@@ -22,7 +22,7 @@ import { createLink } from "../../../library-components/ATag";
22
22
  import { showingManagementURL, managementPageURL } from "../../managementPages";
23
23
  import { atomic } from "../../../2-proxy/PathValueProxyWatcher";
24
24
  import { magenta } from "socket-function/src/formatting/logColors";
25
- import { exposeTicketService } from "../errorTickets/tickets";
25
+ import { TicketServiceBase } from "../errorTickets/tickets";
26
26
 
27
27
 
28
28
  export type SuppressionEntry = {
@@ -307,7 +307,7 @@ const trySendDiscordNotificationsBase = batchFunction({ delay: 1000 * 3 }, async
307
307
 
308
308
  export async function exposeErrorWatchService() {
309
309
  SocketFunction.expose(ErrorNotificationServiceBase);
310
- exposeTicketService();
310
+ SocketFunction.expose(TicketServiceBase);
311
311
 
312
312
  let errorLogs = await getErrorLogs();
313
313
  for await (let error of watchAllValues(errorLogs)) {
@@ -204,14 +204,10 @@ export const TicketServiceBase = SocketFunction.register(
204
204
  }
205
205
  );
206
206
 
207
- export function exposeTicketService() {
208
- SocketFunction.expose(TicketServiceBase);
209
- }
210
-
211
207
  async function getTicketServiceNode(): Promise<string> {
212
- let controllerNodeId = await getControllerNodeId(TicketServiceBase, !isPublic());
208
+ let controllerNodeId = await getControllerNodeId(TicketServiceBase);
213
209
  if (!controllerNodeId) {
214
- throw new Error(`Could not find node exposing controller TicketServiceBase. Is \`yarn tickets\` running?`);
210
+ throw new Error(`Could not find node exposing controller TicketServiceBase. Is the \`yarn error-watch\` service running?`);
215
211
  }
216
212
  return controllerNodeId;
217
213
  }