mnfst-render 0.5.6 → 0.5.7

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.
Files changed (2) hide show
  1. package/manifest.render.mjs +28 -17
  2. package/package.json +1 -1
@@ -150,11 +150,11 @@ async function waitForManifestRenderReady(page, { allLocales, currentLocale, tim
150
150
  )
151
151
  .catch((e) => ({ ok: false, reason: 'evaluate', message: String(e) }));
152
152
 
153
- if (!result?.ok) {
154
- const parts = [`prerender: render-ready wait incomplete (${result?.reason ?? 'unknown'})`];
155
- if (result?.message) parts.push(result.message);
156
- process.stdout.write(`${parts.join('; ')}\n`);
157
- }
153
+ // Note: render-ready wait timeouts are silently tolerated. Earlier versions
154
+ // logged a warning per path, but it fires on essentially every route in
155
+ // projects whose data plugins don't dispatch `manifest:render-ready` (i.e.
156
+ // most of them), drowning the terminal in noise. The fallback timeout is
157
+ // intentional and benign — the DOM is still captured.
158
158
  }
159
159
 
160
160
  // --- Config ------------------------------------------------------------------
@@ -246,7 +246,11 @@ function resolveConfig() {
246
246
  : [],
247
247
  dryRun: !!cli.dryRun,
248
248
  debugPrerender: !!cli.debugPrerender,
249
- pipelineTimeout: 25000,
249
+ // Cap on the manifest:render-ready wait. When the data plugin dispatches
250
+ // the event, we resolve immediately; when it doesn't (most projects), we
251
+ // fall back to the timeout. Lowered from 25000 — the earlier settle
252
+ // waits already give plugins enough time to finish.
253
+ pipelineTimeout: 6000,
250
254
  };
251
255
  }
252
256
 
@@ -2024,16 +2028,21 @@ async function runPrerender(config) {
2024
2028
  timeout: Math.min(timeout, 30000),
2025
2029
  });
2026
2030
 
2031
+ // Belt-and-suspenders settle waits. Each one is bounded short because
2032
+ // the authoritative `manifest:render-ready` wait below is what we really
2033
+ // rely on. These earlier waits exist as fallbacks for projects whose
2034
+ // data plugins don't dispatch the modern signal — but they shouldn't
2035
+ // dominate per-path runtime when they DO time out.
2027
2036
  await Promise.race([
2028
2037
  page.evaluate(() => {
2029
2038
  return new Promise((resolve) => {
2030
2039
  const done = () => resolve();
2031
- const t = setTimeout(done, 6000);
2040
+ const t = setTimeout(done, 1500); // was 6000
2032
2041
  window.addEventListener(
2033
2042
  'manifest:routing-ready',
2034
2043
  () => {
2035
2044
  clearTimeout(t);
2036
- setTimeout(done, 2000);
2045
+ setTimeout(done, 500); // was 2000
2037
2046
  },
2038
2047
  { once: true }
2039
2048
  );
@@ -2042,13 +2051,13 @@ async function runPrerender(config) {
2042
2051
  new Promise((_, rej) => setTimeout(() => rej(new Error('ready timeout')), timeout)),
2043
2052
  ]).catch(() => { });
2044
2053
 
2045
- // Ensure manifest.min.js (dynamic loader) has run and injected plugin scripts before snapshot.
2046
- // Static output still runs the loader and Alpine; we just capture the DOM after they've set up.
2054
+ // Ensure the dynamic loader has injected at least one plugin script.
2055
+ // In practice this happens within ~100ms; the 1500ms cap is generous.
2047
2056
  await page.evaluate(() => {
2048
2057
  return new Promise((resolve) => {
2049
2058
  const check = () => document.querySelectorAll('script[src*="manifest"]').length >= 2;
2050
2059
  if (check()) return resolve();
2051
- const deadline = Date.now() + 5000;
2060
+ const deadline = Date.now() + 1500; // was 5000
2052
2061
  const t = setInterval(() => {
2053
2062
  if (check() || Date.now() >= deadline) {
2054
2063
  clearInterval(t);
@@ -2058,19 +2067,21 @@ async function runPrerender(config) {
2058
2067
  });
2059
2068
  }).catch(() => { });
2060
2069
 
2061
- await page.waitForNetworkIdle({ idleTime: 1500, timeout: 10000 }).catch(() => { });
2070
+ // Network idle: shorter idle window + shorter cap. Most plugin scripts
2071
+ // and data fetches complete in under 2s on a healthy local server.
2072
+ await page.waitForNetworkIdle({ idleTime: 800, timeout: 4000 }).catch(() => { });
2062
2073
 
2074
+ // DOM stability: 300ms quiet window is plenty after networkIdle has
2075
+ // already drained pending fetches.
2063
2076
  await page.evaluate(() => {
2064
2077
  return new Promise((resolve) => {
2065
2078
  const observer = new MutationObserver(() => {
2066
2079
  clearTimeout(stable);
2067
- stable = setTimeout(resolve, 800);
2080
+ stable = setTimeout(finish, 300); // was 800
2068
2081
  });
2069
2082
  observer.observe(document.documentElement, { childList: true, subtree: true, characterData: true });
2070
- let stable = setTimeout(() => {
2071
- observer.disconnect();
2072
- resolve();
2073
- }, 800);
2083
+ const finish = () => { observer.disconnect(); resolve(); };
2084
+ let stable = setTimeout(finish, 300); // was 800
2074
2085
  });
2075
2086
  }).catch(() => { });
2076
2087
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-render",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {