querysub 0.599.0 → 0.601.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.599.0",
3
+ "version": "0.601.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",
@@ -25,6 +25,7 @@ import { getGitRefLive, getGitURLLive } from "./git";
25
25
  import { DeployProgress } from "./deployFunctions";
26
26
  import { PromiseObj } from "../promise";
27
27
  import type { FunctionRunnerIndex } from "../4-querysub/FunctionRunnerTracking";
28
+ import { unique } from "../misc";
28
29
 
29
30
  const UPDATE_POLL_INTERVAL = timeInMinute * 15;
30
31
  const DEAD_NODE_COUNT_THRESHOLD = 15;
@@ -314,7 +315,7 @@ async function updateEdgeNodesFile() {
314
315
  }
315
316
 
316
317
  let edgeNodeFiles = await edgeNodeStorage.find("node", { type: "files" });
317
- let edgeNodeNodeIds = edgeNodeFiles.map(getNodeIdFromPath);
318
+ let edgeNodeNodeIds = unique(edgeNodeFiles.map(getNodeIdFromPath));
318
319
 
319
320
  let liveHash = "";
320
321
  if (!noSyncing()) {
@@ -296,11 +296,11 @@ export function getSyncedController<T extends {
296
296
  // We have to wait until we actually commit before making the call. Otherwise, if this commit is rejected because we need to do synchronized values, we'll call the function twice.
297
297
  let fnc = controller.nodes[nodeId][fncName] as any;
298
298
  // NOTE: We can't do on commit finish because we later have a trigger on promise finish for our own promise. And if we don't start the promise call until we finish the commit, And we can't finish the commit until we start the promise call, it'll never finish. So... The best we can do is just check for if everything's synced at this current point.
299
- if (Querysub.isAllSynced()) {
299
+ Querysub.onCommitFinished(() => {
300
300
  void Promise.resolve().then(() => {
301
301
  doPromiseCall();
302
302
  });
303
- }
303
+ });
304
304
  function doPromiseCall() {
305
305
  let promise = fnc(...args) as Promise<unknown>;
306
306
  promiseObjBase.resolve(promise);
@@ -349,11 +349,13 @@ export function getSyncedController<T extends {
349
349
  }
350
350
  }
351
351
  currentPromise = currentPromise || promise?.promise;
352
- if (currentPromise) {
353
- Querysub.triggerOnPromiseFinish(currentPromise, {
354
- waitReason: `Waiting for ${fncName} to finish`,
355
- });
356
- }
352
+ // NOTE: We do somewhat want this if it's a function that's called inside of a render function. However, a lot of the time this is called just as a promise function, in which case we don't want to rerun the event handler.
353
+ // ALSO, We really want to only call the promise on commit finished. Before I thought we could do it if isAll synced, but that doesn't mean we're not going to run again, and we don't want to call the promise function multiple times ever. And if we block here, Then commit finish is blocked so... We can't block committing for synced controller functions.
354
+ // if (currentPromise) {
355
+ // Querysub.triggerOnPromiseFinish(currentPromise, {
356
+ // waitReason: `Waiting for ${fncName} to finish`,
357
+ // });
358
+ // }
357
359
  return undefined;
358
360
  }
359
361
  call.promise = (...args: any[]) => {