querysub 0.439.0 → 0.441.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.439.0",
3
+ "version": "0.441.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",
@@ -61,10 +61,9 @@
61
61
  "node-forge": "https://github.com/sliftist/forge#e618181b469b07bdc70b968b0391beb8ef5fecd6",
62
62
  "pako": "^2.1.0",
63
63
  "peggy": "^5.0.6",
64
- "querysub": "^0.357.0",
65
- "socket-function": "^1.1.21",
64
+ "socket-function": "^1.1.23",
66
65
  "terser": "^5.31.0",
67
- "typesafecss": "^0.28.0",
66
+ "typesafecss": "^0.29.0",
68
67
  "yaml": "^2.5.0",
69
68
  "yargs": "^15.3.1"
70
69
  },
@@ -136,4 +136,4 @@ export async function addRecord(type: string, key: string, value: string, proxie
136
136
  console.log(`${ttlLeft} seconds left...`);
137
137
  }
138
138
  console.log(`Done waiting for DNS to update.`);
139
- }
139
+ }
@@ -1192,7 +1192,7 @@ export class PathValueProxyWatcher {
1192
1192
  };
1193
1193
  watcher.hasAnyUnsyncedAccesses = () => {
1194
1194
  if (watcher.options.waitForIncompleteTransactions) {
1195
- waitIfReceivedIncompleteTransaction();
1195
+ waitIfReceivedIncompleteTransaction(watcher);
1196
1196
  }
1197
1197
  return (
1198
1198
  watcher.pendingUnsyncedAccesses.size > 0
@@ -1,6 +1,6 @@
1
1
  import { delay } from "socket-function/src/batching";
2
2
  import { PathValue, hashPathForTransaction, compareTime, Time } from "../0-path-value-core/pathValueCore";
3
- import { proxyWatcher } from "./PathValueProxyWatcher";
3
+ import { SyncWatcher, proxyWatcher } from "./PathValueProxyWatcher";
4
4
 
5
5
  const MISSING_TRANSACTION_PART_TIMEOUT = 5000;
6
6
 
@@ -62,9 +62,8 @@ export function isMissingTransactionPart(pathValues: PathValue[]): { time: numbe
62
62
  return newestWaitTime;
63
63
  }
64
64
 
65
- export function getAllPendingPathValueReads() {
65
+ export function getAllPendingPathValueReads(watcher = proxyWatcher.getTriggeredWatcher()) {
66
66
  let values: PathValue[] = [];
67
- let watcher = proxyWatcher.getTriggeredWatcher();
68
67
  for (let map of watcher.pendingAccesses.values()) {
69
68
  for (let pathValue of map.values()) {
70
69
  values.push(pathValue.pathValue);
@@ -74,13 +73,11 @@ export function getAllPendingPathValueReads() {
74
73
  }
75
74
 
76
75
 
77
- export function waitIfReceivedIncompleteTransaction() {
78
- // 1) Keep track of the last proxy watcher we just registered it for. And then if the proxy watcher is the same as that one and that proxy watcher is waiting on a promise, don't register it again.
79
- let watcher = proxyWatcher.getTriggeredWatcher();
76
+ export function waitIfReceivedIncompleteTransaction(watcher: SyncWatcher) {
80
77
  // We don't want to register a whole bunch of duplicate promises. So if somebody's waiting, there's no need to even do our check.
81
78
  if (watcher.specialPromiseUnsynced) return;
82
79
 
83
- let newestTime = isMissingTransactionPart(getAllPendingPathValueReads());
80
+ let newestTime = isMissingTransactionPart(getAllPendingPathValueReads(watcher));
84
81
  if (!newestTime) return;
85
82
 
86
83
  let timeout = newestTime.time + MISSING_TRANSACTION_PART_TIMEOUT;
@@ -10,7 +10,7 @@ Promise.race = PromiseRace;
10
10
  import { shimDateNow } from "socket-function/time/trueTimeShim";
11
11
  shimDateNow();
12
12
 
13
- import { isNode, isNodeTrue, timeInMinute, timeInSecond, timeoutToUndefined } from "socket-function/src/misc";
13
+ import { isNode, isNodeTrue, nextId, timeInMinute, timeInSecond, timeoutToUndefined } from "socket-function/src/misc";
14
14
 
15
15
  import { SocketFunction } from "socket-function/SocketFunction";
16
16
  import { isHotReloading, watchFilesAndTriggerHotReloading } from "socket-function/hot/HotReloadController";
@@ -183,6 +183,9 @@ export class Querysub {
183
183
  public static AUDIT_PREDICTIONS = true;
184
184
  public static SIMULATE_LAG = 0;
185
185
 
186
+ public static registerAliveChecker = <T>(config: AliveChecker<T>) => registerAliveChecker(config);
187
+ public static registerGarbageCollection = <T>(config: AliveChecker<T>) => registerAliveChecker(config);
188
+
186
189
  /** Delay used when functions are specified as delayCommit */
187
190
  public static DELAY_COMMIT_DELAY = 1000 * 3;
188
191
 
@@ -218,7 +221,10 @@ export class Querysub {
218
221
  // Returns a random value between 0 and 1. The value depends on the callId, and index (being identical for
219
222
  // the same callid and index).
220
223
  public static callRandom = () => hashRandom(Querysub.getCallId(), getNextCallIndex());
221
- public static nextId = () => Querysub.getCallId() + "_" + getNextCallIndex();
224
+ public static nextId = () => {
225
+ if (!Querysub.isInSyncedCall()) return nextId();
226
+ return Querysub.getCallId() + "_" + getNextCallIndex();
227
+ };
222
228
 
223
229
  public static getNextCallIndex = getNextCallIndex;
224
230
 
@@ -1336,4 +1342,5 @@ import { onAllPredictionsFinished } from "../-0-hooks/hooks";
1336
1342
  import { LOCAL_DOMAIN } from "../0-path-value-core/PathRouter";
1337
1343
  import { authorityLookup } from "../0-path-value-core/AuthorityLookup";
1338
1344
  import { encodeParentFilter } from "../0-path-value-core/hackedPackedPathParentFiltering";
1345
+ import { AliveChecker, registerAliveChecker } from "../2-proxy/garbageCollection";
1339
1346
 
@@ -4,7 +4,7 @@ import { qreact } from "../../4-dom/qreact";
4
4
  import { deployGetFunctions } from "../../4-deploy/deployFunctions";
5
5
  import { MachineServiceController, deployFunctionsWithProgress } from "../machineSchema";
6
6
  import { functionSchema, FunctionSpec } from "../../3-path-functions/PathFunctionRunner";
7
- import { getDomain } from "../../config";
7
+ import { getDomain, isPublic } from "../../config";
8
8
  import { RenderGitRefInfo, UpdateButtons, bigEmoji, buttonStyle } from "./deployButtons";
9
9
  import { css } from "typesafecss";
10
10
  import { timeInHour, timeInMinute } from "socket-function/src/misc";
@@ -269,6 +269,7 @@ export class DeployPage extends qreact.Component {
269
269
 
270
270
  return <div className={css.vbox(40).marginTop(20)}>
271
271
  <div className={css.hbox(10)}>
272
+ {isPublic() && <h1>Don't deploy on public servers! It won't work, it will just deploy what that server is already running. TODO: Fix this.</h1>}
272
273
  <UpdateButtons services={[]} />
273
274
  <button
274
275
  disabled={controller.isAnyLoading()}
@@ -756,14 +756,20 @@ export class IndexedLogs<T> {
756
756
  }
757
757
  }
758
758
 
759
+
760
+ function getLogByName(name: string): IndexedLogs<unknown> {
761
+ let indexedLogs = loggerByName.get(name);
762
+ if (!indexedLogs) throw new Error(`Indexed logs ${name} not found, have ${Array.from(loggerByName.keys()).join(" | ")}`);
763
+ return indexedLogs;
764
+ }
759
765
  class IndexedLogClient {
766
+
760
767
  public async onFind(config: {
761
768
  findId: string;
762
769
  indexedLogsName: string;
763
770
  result: unknown;
764
771
  }) {
765
- let indexedLogs = loggerByName.get(config.indexedLogsName);
766
- if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
772
+ let indexedLogs = getLogByName(config.indexedLogsName);
767
773
  indexedLogs.onFindResult({
768
774
  findId: config.findId,
769
775
  result: config.result,
@@ -774,8 +780,7 @@ class IndexedLogClient {
774
780
  indexedLogsName: string;
775
781
  results: IndexedLogResults;
776
782
  }): Promise<boolean> {
777
- let indexedLogs = loggerByName.get(config.indexedLogsName);
778
- if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
783
+ let indexedLogs = getLogByName(config.indexedLogsName);
779
784
  return await indexedLogs.onResults({
780
785
  findId: config.findId,
781
786
  results: config.results,
@@ -789,8 +794,7 @@ class IndexedLogShim {
789
794
  params: SearchParams;
790
795
  }): Promise<IndexedLogResults> {
791
796
  let caller = SocketFunction.getCaller();
792
- let indexedLogs = loggerByName.get(config.indexedLogsName);
793
- if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
797
+ let indexedLogs = getLogByName(config.indexedLogsName);
794
798
 
795
799
  return indexedLogs.find({
796
800
  params: config.params,
@@ -822,8 +826,7 @@ class IndexedLogShim {
822
826
  only?: "local" | "public";
823
827
  forceReadProduction?: boolean;
824
828
  }): Promise<TimeFilePathWithSize[]> {
825
- let indexedLogs = loggerByName.get(config.indexedLogsName);
826
- if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
829
+ let indexedLogs = getLogByName(config.indexedLogsName);
827
830
  return indexedLogs.getPaths({
828
831
  startTime: config.startTime,
829
832
  endTime: config.endTime,
@@ -835,8 +838,7 @@ class IndexedLogShim {
835
838
  public async forceMoveLogsToPublic(config: {
836
839
  indexedLogsName: string;
837
840
  }) {
838
- let indexedLogs = loggerByName.get(config.indexedLogsName);
839
- if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
841
+ let indexedLogs = getLogByName(config.indexedLogsName);
840
842
  await indexedLogs.moveLogsToPublic(true);
841
843
  }
842
844