@absolutejs/absolute 0.20.0-beta.109 → 0.20.0-beta.110

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.
@@ -707,6 +707,13 @@ var absoluteServerEntryCopyOwnerPid = (name) => {
707
707
  const pid = Number(match[1]);
708
708
  return Number.isSafeInteger(pid) && pid > 0 ? pid : null;
709
709
  };
710
+ var isMissingAbsoluteServerEntryCopyError = (error, copyPath) => {
711
+ if (!(error instanceof Error))
712
+ return false;
713
+ const quotedPath = `'${copyPath}'`;
714
+ const doubleQuotedPath = `"${copyPath}"`;
715
+ return (error.message.includes(`Cannot find module ${quotedPath}`) || error.message.includes(`Cannot find module ${doubleQuotedPath}`)) && !error.message.includes(`from ${quotedPath}`) && !error.message.includes(`from ${doubleQuotedPath}`);
716
+ };
710
717
  var isProcessAlive = (pid) => {
711
718
  try {
712
719
  process.kill(pid, 0);
@@ -753,13 +760,17 @@ if (!isHotReevaluation) {
753
760
  removeEntryCopy(join2(entryDir, name));
754
761
  }
755
762
  }
756
- var bootstrapSequence = (globalThis.__absoluteEntryBootstrapSequence ?? 0) + 1;
757
- globalThis.__absoluteEntryBootstrapSequence = bootstrapSequence;
758
- var bootstrapCopy = join2(entryDir, `${copyPrefix}${process.pid}-bootstrap-${bootstrapSequence}${entryExtension}`);
759
- copyFileSync2(entryPath, bootstrapCopy);
760
763
  var entryCopies = globalThis.__absoluteEntryCopies ?? new Set;
761
- entryCopies.add(bootstrapCopy);
762
764
  globalThis.__absoluteEntryCopies = entryCopies;
765
+ var createBootstrapCopy = () => {
766
+ const sequence = (globalThis.__absoluteEntryBootstrapSequence ?? 0) + 1;
767
+ globalThis.__absoluteEntryBootstrapSequence = sequence;
768
+ const path = join2(entryDir, `${copyPrefix}${process.pid}-bootstrap-${sequence}${entryExtension}`);
769
+ copyFileSync2(entryPath, path);
770
+ entryCopies.add(path);
771
+ return path;
772
+ };
773
+ var bootstrapCopy = createBootstrapCopy();
763
774
  if (!globalThis.__absoluteEntryCleanupRegistered) {
764
775
  globalThis.__absoluteEntryCleanupRegistered = true;
765
776
  process.on("exit", () => {
@@ -822,7 +833,25 @@ if (importCostRecorder !== undefined) {
822
833
  importCostRecorder.rootModule = import.meta.path;
823
834
  }
824
835
  markBoot("server entry import start");
825
- await import(bootstrapCopy);
836
+ var MAX_BOOTSTRAP_IMPORT_ATTEMPTS = 3;
837
+ var recordBootstrapImportCostEntry = () => {
838
+ if (importCostRecorder === undefined)
839
+ return;
840
+ importCostRecorder.entryModule = bootstrapCopy;
841
+ };
842
+ var importBootstrapCopy = async (attempt = 1) => {
843
+ try {
844
+ await import(bootstrapCopy);
845
+ } catch (error) {
846
+ if (attempt >= MAX_BOOTSTRAP_IMPORT_ATTEMPTS || !isMissingAbsoluteServerEntryCopyError(error, bootstrapCopy)) {
847
+ throw error;
848
+ }
849
+ bootstrapCopy = createBootstrapCopy();
850
+ recordBootstrapImportCostEntry();
851
+ await importBootstrapCopy(attempt + 1);
852
+ }
853
+ };
854
+ await importBootstrapCopy();
826
855
  markBoot("server entry import done");
827
856
  await globalThis.__absoluteImportCostReport?.();
828
857
  printImportCostHint({ hotReevaluation: isHotReevaluation });