@vertz/ui-server 0.2.31 → 0.2.32

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.
@@ -2883,6 +2883,7 @@ var BUILD_ERROR_LOADER = [
2883
2883
  "fetch(src).then(function(r){return r.text()}).then(function(t){",
2884
2884
  "if(t.trimStart().startsWith('try{location.reload()}')){",
2885
2885
  "fetch('/__vertz_build_check').then(function(r){return r.json()}).then(function(j){",
2886
+ `if(j.restarting){showOverlay('Restarting dev server','<p style="margin:0;color:#666;font-size:12px">Stale module graph detected. Restarting...</p>');sessionStorage.removeItem('__vertz_stub_retry');return}`,
2886
2887
  "if(j.errors&&j.errors.length>0){showOverlay('Build failed',formatErrors(j.errors),j)}",
2887
2888
  "else{var V2=window.__vertz_overlay;",
2888
2889
  "if(V2&&V2._autoRestart&&V2._canAutoRestart&&V2._canAutoRestart()){",
@@ -3045,6 +3046,7 @@ function createBunDevServer(options) {
3045
3046
  pendingRuntimeError = null;
3046
3047
  }
3047
3048
  clearGraceUntil = Date.now() + 5000;
3049
+ autoRestartTimestamps.length = 0;
3048
3050
  const msg = JSON.stringify({ type: "clear" });
3049
3051
  for (const ws of wsClients) {
3050
3052
  ws.sendText(msg);
@@ -3061,6 +3063,7 @@ function createBunDevServer(options) {
3061
3063
  pendingRuntimeError = null;
3062
3064
  }
3063
3065
  clearGraceUntil = 0;
3066
+ autoRestartTimestamps.length = 0;
3064
3067
  const msg = JSON.stringify({ type: "clear" });
3065
3068
  for (const ws of wsClients) {
3066
3069
  ws.sendText(msg);
@@ -3488,6 +3491,20 @@ if (import.meta.hot) import.meta.hot.accept();
3488
3491
  if (lastBuildError) {
3489
3492
  return Response.json({ errors: [{ message: lastBuildError }] });
3490
3493
  }
3494
+ if (bundledScriptUrl && !isRestarting && canAutoRestart()) {
3495
+ try {
3496
+ const bundleRes = await fetch(`http://${host}:${server?.port}${bundledScriptUrl}`);
3497
+ const bundleText = await bundleRes.text();
3498
+ if (isReloadStub(bundleText)) {
3499
+ autoRestartTimestamps.push(Date.now());
3500
+ if (logRequests) {
3501
+ console.log("[Server] Build check: dev bundler stale \u2014 restarting");
3502
+ }
3503
+ devServer.restart();
3504
+ return Response.json({ errors: [], restarting: true });
3505
+ }
3506
+ } catch {}
3507
+ }
3491
3508
  return Response.json({ errors: [] });
3492
3509
  } catch (e) {
3493
3510
  const msg = e instanceof Error ? e.message : String(e);
@@ -3852,6 +3869,27 @@ data: {}
3852
3869
  console.warn("[Server] Could not discover HMR bundled URL:", e);
3853
3870
  }
3854
3871
  }
3872
+ async function checkAndRestartIfBundlerStale() {
3873
+ if (!bundledScriptUrl || !server || isRestarting)
3874
+ return false;
3875
+ try {
3876
+ const bundleRes = await fetch(`http://${host}:${server.port}${bundledScriptUrl}`);
3877
+ const bundleText = await bundleRes.text();
3878
+ if (isReloadStub(bundleText)) {
3879
+ if (canAutoRestart()) {
3880
+ autoRestartTimestamps.push(Date.now());
3881
+ if (logRequests) {
3882
+ console.log("[Server] Dev bundler still serving reload stub after SSR recovery \u2014 restarting");
3883
+ }
3884
+ devServer.restart();
3885
+ return true;
3886
+ } else if (logRequests) {
3887
+ console.log("[Server] Dev bundler stale but auto-restart cap reached");
3888
+ }
3889
+ }
3890
+ } catch {}
3891
+ return false;
3892
+ }
3855
3893
  stopped = false;
3856
3894
  if (existsSync2(srcDir)) {
3857
3895
  srcWatcherRef = watch2(srcDir, { recursive: true }, (_event, filename) => {
@@ -3927,7 +3965,6 @@ data: {}
3927
3965
  }
3928
3966
  } catch {}
3929
3967
  }
3930
- clearErrorForFileChange();
3931
3968
  }
3932
3969
  } catch {}
3933
3970
  if (stopped)
@@ -3977,8 +4014,10 @@ data: {}
3977
4014
  return;
3978
4015
  }
3979
4016
  if (logRequests) {
3980
- console.log("[Server] SSR in fallback mode \u2014 attempting re-import (best effort)");
4017
+ console.log("[Server] SSR in fallback mode \u2014 restarting dev server");
3981
4018
  }
4019
+ devServer.restart();
4020
+ return;
3982
4021
  }
3983
4022
  const cacheCleared = clearSSRRequireCache();
3984
4023
  logger.log("watcher", "cache-cleared", { entries: cacheCleared });
@@ -4002,6 +4041,9 @@ data: {}
4002
4041
  if (logRequests) {
4003
4042
  console.log("[Server] SSR module refreshed");
4004
4043
  }
4044
+ if (await checkAndRestartIfBundlerStale())
4045
+ return;
4046
+ clearErrorForFileChange();
4005
4047
  } catch {
4006
4048
  logger.log("watcher", "ssr-reload", { status: "retry" });
4007
4049
  if (stopped)
@@ -4028,6 +4070,9 @@ data: {}
4028
4070
  if (logRequests) {
4029
4071
  console.log("[Server] SSR module refreshed (retry)");
4030
4072
  }
4073
+ if (await checkAndRestartIfBundlerStale())
4074
+ return;
4075
+ clearErrorForFileChange();
4031
4076
  } catch (e2) {
4032
4077
  console.error("[Server] Failed to refresh SSR module:", e2);
4033
4078
  const errMsg = e2 instanceof Error ? e2.message : String(e2);