@514labs/moose-lib 0.6.267-ci-2-g580f80e4 → 0.6.267-ci-5-gfe9b0c33

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/dist/index.mjs CHANGED
@@ -702,15 +702,43 @@ if (getMooseInternal() === void 0) {
702
702
  var indexLoadState = "unloaded";
703
703
  var indexLoadPromise = null;
704
704
  var loadIndex = async () => {
705
+ const workerInfo = `[Worker ${process2.pid}]`;
705
706
  if (indexLoadState === "loaded") {
707
+ console.log(
708
+ `${workerInfo} loadIndex: already loaded, returning immediately`
709
+ );
706
710
  return;
707
711
  }
708
712
  if (indexLoadState === "loading" && indexLoadPromise) {
713
+ console.log(
714
+ `${workerInfo} loadIndex: already loading, waiting for completion`
715
+ );
709
716
  return indexLoadPromise;
710
717
  }
718
+ console.log(`${workerInfo} loadIndex: starting load process`);
719
+ const startTime = Date.now();
720
+ const delay = Math.random() * 500;
721
+ console.log(
722
+ `${workerInfo} loadIndex: waiting ${delay.toFixed(0)}ms to stagger load`
723
+ );
724
+ await new Promise((resolve) => setTimeout(resolve, delay));
725
+ if (indexLoadState === "loading" && indexLoadPromise) {
726
+ console.log(
727
+ `${workerInfo} loadIndex: another worker started loading during delay, waiting`
728
+ );
729
+ return indexLoadPromise;
730
+ }
731
+ if (indexLoadState === "loaded") {
732
+ console.log(
733
+ `${workerInfo} loadIndex: loaded by another worker during delay`
734
+ );
735
+ return;
736
+ }
711
737
  indexLoadState = "loading";
712
738
  indexLoadPromise = (async () => {
713
739
  try {
740
+ console.log(`${workerInfo} loadIndex: clearing registry...`);
741
+ const clearStart = Date.now();
714
742
  const registry = getMooseInternal();
715
743
  registry.tables.clear();
716
744
  registry.streams.clear();
@@ -719,15 +747,35 @@ var loadIndex = async () => {
719
747
  registry.sqlResources.clear();
720
748
  registry.workflows.clear();
721
749
  registry.webApps.clear();
750
+ console.log(
751
+ `${workerInfo} loadIndex: registry cleared in ${Date.now() - clearStart}ms`
752
+ );
753
+ console.log(`${workerInfo} loadIndex: clearing require cache...`);
754
+ const cacheStart = Date.now();
722
755
  const appDir = `${process2.cwd()}/${getSourceDir()}`;
723
756
  Object.keys(__require.cache).forEach((key) => {
724
757
  if (key.startsWith(appDir)) {
725
758
  delete __require.cache[key];
726
759
  }
727
760
  });
761
+ console.log(
762
+ `${workerInfo} loadIndex: require cache cleared in ${Date.now() - cacheStart}ms`
763
+ );
764
+ console.log(`${workerInfo} loadIndex: requiring index.ts...`);
765
+ const requireStart = Date.now();
728
766
  __require(`${process2.cwd()}/${getSourceDir()}/index.ts`);
767
+ console.log(
768
+ `${workerInfo} loadIndex: require completed in ${Date.now() - requireStart}ms`
769
+ );
729
770
  indexLoadState = "loaded";
771
+ console.log(
772
+ `${workerInfo} loadIndex: total load time ${Date.now() - startTime}ms`
773
+ );
730
774
  } catch (error) {
775
+ console.error(
776
+ `${workerInfo} loadIndex: FAILED after ${Date.now() - startTime}ms`,
777
+ error
778
+ );
731
779
  indexLoadState = "unloaded";
732
780
  indexLoadPromise = null;
733
781
  let hint;