querysub 0.161.0 → 0.162.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.161.0",
3
+ "version": "0.162.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",
@@ -266,6 +266,19 @@ function getCallstackFiles(): string[] {
266
266
  return files;
267
267
  }
268
268
 
269
+ let importBlockers = new Set<Promise<unknown>>();
270
+ export function registerImportBlockers(blocker: Promise<unknown>) {
271
+ importBlockers.add(blocker);
272
+ void blocker.finally(() => {
273
+ importBlockers.delete(blocker);
274
+ });
275
+ }
276
+ export async function waitForImportBlockers() {
277
+ while (importBlockers.size > 0) {
278
+ await Promise.all(Array.from(importBlockers));
279
+ }
280
+ }
281
+
269
282
  async function getModuleFromSpecBase(
270
283
  spec: LoadFunctionSpec
271
284
  ): Promise<NodeJS.Module> {
@@ -314,10 +327,7 @@ async function getModuleFromSpecBase(
314
327
  // NOTE: The true tells require to not warn about the async loading
315
328
  await (require as any)(path, true);
316
329
 
317
- // Unfortunately... we have to wait for some delayed imports to finish.
318
- // This isn't great, but it is important to set LazyComponent imports
319
- // with the correct git hash.
320
- await delay(0);
330
+ await waitForImportBlockers();
321
331
  });
322
332
  });
323
333
  } catch (e: any) {
@@ -25,6 +25,7 @@ import { timeInHour } from "socket-function/src/misc";
25
25
  import { preloadUI } from "./edgeNodes";
26
26
  import { shutdown } from "../diagnostics/periodic";
27
27
  import { delay } from "socket-function/src/batching";
28
+ import { waitForImportBlockers } from "../3-path-functions/pathFunctionLoader";
28
29
 
29
30
  let yargObj = yargs(process.argv)
30
31
  .option("domain", { type: "string", required: true, desc: "Domain to deploy to" })
@@ -54,7 +55,7 @@ export async function deployMain() {
54
55
  require(deployPath);
55
56
 
56
57
  // Wait for Promise.resolve imports to import
57
- await delay(0);
58
+ await waitForImportBlockers();
58
59
 
59
60
  const srcRoot = path.resolve(__dirname + "/../").replaceAll("\\", "/");
60
61
 
@@ -3,6 +3,7 @@ import { cache, lazy } from "socket-function/src/caching";
3
3
  import { isNode, sort } from "socket-function/src/misc";
4
4
  import { Querysub } from "../4-querysub/QuerysubController";
5
5
  import { qreact } from "../4-dom/qreact";
6
+ import { registerImportBlockers } from "../3-path-functions/pathFunctionLoader";
6
7
 
7
8
  let nextSeqNum = 0;
8
9
  let schema = Querysub.createLocalSchema<{
@@ -18,7 +19,7 @@ export function createLazyComponent<Module>(
18
19
  return (exportName) => {
19
20
  if (isNode()) {
20
21
  // Import it, asynchronously, so it isn't preloaded, but it is available for clientside imports.
21
- void Promise.resolve().then(() => getImport());
22
+ registerImportBlockers(Promise.resolve().then(() => getImport()));
22
23
  // TOOD: We will need to support this serverside eventually.
23
24
  return class extends qreact.Component {
24
25
  render(): preact.ComponentChild {