@rsc-kit/core 0.31.2 → 0.31.3

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/devLock.d.ts CHANGED
@@ -11,7 +11,10 @@
11
11
  * `bun run dev` in a terminal.
12
12
  *
13
13
  * So the first dev server holds a lock in Vite's cache directory - the thing
14
- * they share - and a second one refuses to start, naming the first.
14
+ * they share - and a second one waits, naming the first, and starts when it
15
+ * stops. Waiting rather than exiting: `artisan dev` restarts a process that
16
+ * exits, so a refusal printed itself five times and gave up, and the app was
17
+ * left with no dev server once the first was stopped.
15
18
  */
16
19
  export interface DevServerHolder {
17
20
  pid: number;
@@ -27,4 +30,12 @@ export declare function claimDevServer(cacheDir: string, pid?: number): DevServe
27
30
  export declare function recordDevServerUrl(cacheDir: string, url: string, pid?: number): void;
28
31
  /** Lets go of the lock, if this process holds it. */
29
32
  export declare function releaseDevServer(cacheDir: string, pid?: number): void;
33
+ /**
34
+ * Waits until this process holds the lock: the holder stopped, or is gone.
35
+ * Resolves at once when the lock was free.
36
+ */
37
+ export declare function waitForDevServer(cacheDir: string, { pid, every }?: {
38
+ pid?: number;
39
+ every?: number;
40
+ }): Promise<void>;
30
41
  export declare function secondDevServerMessage(root: string, held: DevServerHolder): string;
package/dist/devLock.js CHANGED
@@ -11,7 +11,10 @@
11
11
  * `bun run dev` in a terminal.
12
12
  *
13
13
  * So the first dev server holds a lock in Vite's cache directory - the thing
14
- * they share - and a second one refuses to start, naming the first.
14
+ * they share - and a second one waits, naming the first, and starts when it
15
+ * stops. Waiting rather than exiting: `artisan dev` restarts a process that
16
+ * exits, so a refusal printed itself five times and gave up, and the app was
17
+ * left with no dev server once the first was stopped.
15
18
  */
16
19
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
17
20
  import { join } from "node:path";
@@ -64,11 +67,20 @@ export function releaseDevServer(cacheDir, pid = process.pid) {
64
67
  }
65
68
  catch { }
66
69
  }
70
+ /**
71
+ * Waits until this process holds the lock: the holder stopped, or is gone.
72
+ * Resolves at once when the lock was free.
73
+ */
74
+ export async function waitForDevServer(cacheDir, { pid = process.pid, every = 1000 } = {}) {
75
+ while (claimDevServer(cacheDir, pid)) {
76
+ await new Promise((resolve) => setTimeout(resolve, every));
77
+ }
78
+ }
67
79
  export function secondDevServerMessage(root, held) {
68
- return (`[rsc-kit] Another dev server is already running for ${root} ` +
69
- `(pid ${held.pid}${held.url ? `, ${held.url}` : ""}). ` +
70
- "Two would share one pre-bundle cache and one hot file, and break each other: " +
71
- "stale pre-bundles (ERR_OUTDATED_OPTIMIZED_DEP), and a backend that loses the renderer when either stops. " +
72
- "Stop that one, or use it - an editor or `artisan dev` may have started it for you.");
80
+ return (`[rsc-kit] A dev server is already running for ${root} ` +
81
+ `(pid ${held.pid}${held.url ? `, ${held.url}` : ""}) - use that one. ` +
82
+ "This one waits and starts when it stops: two at once would share one pre-bundle cache " +
83
+ "and one hot file, and break each other (ERR_OUTDATED_OPTIMIZED_DEP). " +
84
+ "An editor, Herd or `artisan dev` may have started the first for you.");
73
85
  }
74
86
  //# sourceMappingURL=devLock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devLock.js","sourceRoot":"","sources":["../src/devLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAOhC,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE5D,SAAS,KAAK,CAAC,GAAW;IACxB,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;IAA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AE,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAClE,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,GAAG;QAAE,OAAO;IAExC,IAAI,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,IAAqB;IACxE,OAAO,CACL,uDAAuD,IAAI,GAAG;QAC9D,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK;QACvD,+EAA+E;QAC/E,2GAA2G;QAC3G,oFAAoF,CACrF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * One dev server per app.\n *\n * Two `vite dev` processes in one project share everything that makes dev\n * work: Vite's pre-bundle cache, rsc-host.json and the hot file the backend\n * finds the renderer by. Each re-bundles the cache under the other, which\n * answers its next request with ERR_OUTDATED_OPTIMIZED_DEP; each writes the\n * hot file, and the one stopped first deletes it from under the one still\n * running, so the backend reports no renderer at all. Nothing pointed at the\n * cause. It happens easily: `artisan dev` started by an editor or Herd, and\n * `bun run dev` in a terminal.\n *\n * So the first dev server holds a lock in Vite's cache directory - the thing\n * they share - and a second one refuses to start, naming the first.\n */\n\nimport { mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst LOCK = \"rsc-kit-dev.json\";\n\nexport interface DevServerHolder {\n pid: number;\n url?: string;\n}\n\nconst lockPath = (cacheDir: string) => join(cacheDir, LOCK);\n\nfunction alive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n // EPERM: it exists, and belongs to someone else.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nfunction read(cacheDir: string): DevServerHolder | null {\n try {\n const held = JSON.parse(readFileSync(lockPath(cacheDir), \"utf-8\")) as DevServerHolder;\n\n return Number.isInteger(held?.pid) ? held : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Takes the lock for this process, or returns the dev server that holds it.\n * A lock left by a process that is gone - killed, crashed - is taken over.\n * This process's own (a restart) is kept.\n */\nexport function claimDevServer(cacheDir: string, pid = process.pid): DevServerHolder | null {\n const held = read(cacheDir);\n\n if (held && held.pid !== pid && alive(held.pid)) return held;\n\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(lockPath(cacheDir), JSON.stringify({ pid }));\n\n return null;\n}\n\n/** Records where this server listens, for the message a second one prints. */\nexport function recordDevServerUrl(cacheDir: string, url: string, pid = process.pid): void {\n if (read(cacheDir)?.pid !== pid) return;\n\n writeFileSync(lockPath(cacheDir), JSON.stringify({ pid, url }));\n}\n\n/** Lets go of the lock, if this process holds it. */\nexport function releaseDevServer(cacheDir: string, pid = process.pid): void {\n if (read(cacheDir)?.pid !== pid) return;\n\n try {\n rmSync(lockPath(cacheDir));\n } catch {}\n}\n\nexport function secondDevServerMessage(root: string, held: DevServerHolder): string {\n return (\n `[rsc-kit] Another dev server is already running for ${root} ` +\n `(pid ${held.pid}${held.url ? `, ${held.url}` : \"\"}). ` +\n \"Two would share one pre-bundle cache and one hot file, and break each other: \" +\n \"stale pre-bundles (ERR_OUTDATED_OPTIMIZED_DEP), and a backend that loses the renderer when either stops. \" +\n \"Stop that one, or use it - an editor or `artisan dev` may have started it for you.\"\n );\n}\n"]}
1
+ {"version":3,"file":"devLock.js","sourceRoot":"","sources":["../src/devLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI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E;QACvE,sEAAsE,CACvE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * One dev server per app.\n *\n * Two `vite dev` processes in one project share everything that makes dev\n * work: Vite's pre-bundle cache, rsc-host.json and the hot file the backend\n * finds the renderer by. Each re-bundles the cache under the other, which\n * answers its next request with ERR_OUTDATED_OPTIMIZED_DEP; each writes the\n * hot file, and the one stopped first deletes it from under the one still\n * running, so the backend reports no renderer at all. Nothing pointed at the\n * cause. It happens easily: `artisan dev` started by an editor or Herd, and\n * `bun run dev` in a terminal.\n *\n * So the first dev server holds a lock in Vite's cache directory - the thing\n * they share - and a second one waits, naming the first, and starts when it\n * stops. Waiting rather than exiting: `artisan dev` restarts a process that\n * exits, so a refusal printed itself five times and gave up, and the app was\n * left with no dev server once the first was stopped.\n */\n\nimport { mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst LOCK = \"rsc-kit-dev.json\";\n\nexport interface DevServerHolder {\n pid: number;\n url?: string;\n}\n\nconst lockPath = (cacheDir: string) => join(cacheDir, LOCK);\n\nfunction alive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n // EPERM: it exists, and belongs to someone else.\n return (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n}\n\nfunction read(cacheDir: string): DevServerHolder | null {\n try {\n const held = JSON.parse(readFileSync(lockPath(cacheDir), \"utf-8\")) as DevServerHolder;\n\n return Number.isInteger(held?.pid) ? held : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Takes the lock for this process, or returns the dev server that holds it.\n * A lock left by a process that is gone - killed, crashed - is taken over.\n * This process's own (a restart) is kept.\n */\nexport function claimDevServer(cacheDir: string, pid = process.pid): DevServerHolder | null {\n const held = read(cacheDir);\n\n if (held && held.pid !== pid && alive(held.pid)) return held;\n\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(lockPath(cacheDir), JSON.stringify({ pid }));\n\n return null;\n}\n\n/** Records where this server listens, for the message a second one prints. */\nexport function recordDevServerUrl(cacheDir: string, url: string, pid = process.pid): void {\n if (read(cacheDir)?.pid !== pid) return;\n\n writeFileSync(lockPath(cacheDir), JSON.stringify({ pid, url }));\n}\n\n/** Lets go of the lock, if this process holds it. */\nexport function releaseDevServer(cacheDir: string, pid = process.pid): void {\n if (read(cacheDir)?.pid !== pid) return;\n\n try {\n rmSync(lockPath(cacheDir));\n } catch {}\n}\n\n/**\n * Waits until this process holds the lock: the holder stopped, or is gone.\n * Resolves at once when the lock was free.\n */\nexport async function waitForDevServer(\n cacheDir: string,\n { pid = process.pid, every = 1000 }: { pid?: number; every?: number } = {},\n): Promise<void> {\n while (claimDevServer(cacheDir, pid)) {\n await new Promise((resolve) => setTimeout(resolve, every));\n }\n}\n\nexport function secondDevServerMessage(root: string, held: DevServerHolder): string {\n return (\n `[rsc-kit] A dev server is already running for ${root} ` +\n `(pid ${held.pid}${held.url ? `, ${held.url}` : \"\"}) - use that one. ` +\n \"This one waits and starts when it stops: two at once would share one pre-bundle cache \" +\n \"and one hot file, and break each other (ERR_OUTDATED_OPTIMIZED_DEP). \" +\n \"An editor, Herd or `artisan dev` may have started the first for you.\"\n );\n}\n"]}
package/dist/vite.js CHANGED
@@ -26,7 +26,7 @@ import { stampDisplayNames } from "./stableNames.js";
26
26
  import { REPORT_FILE, buildReport } from "./buildReport.js";
27
27
  import { contractPath, edgeGuarded, edgeMarker, edgeShells, edgeStatic } from "./edgeShells.js";
28
28
  import { EDGE, EDGE_HEADERS } from "./headers.js";
29
- import { claimDevServer, recordDevServerUrl, releaseDevServer, secondDevServerMessage } from "./devLock.js";
29
+ import { claimDevServer, recordDevServerUrl, releaseDevServer, secondDevServerMessage, waitForDevServer } from "./devLock.js";
30
30
  import { devContentSecurityPolicy, normaliseContentSecurityPolicy, } from "./csp.js";
31
31
  import { MANIFEST_PATH, manifestWarning, webManifest } from "./webManifest.js";
32
32
  import { ASSET_BASE, allAppAssets, assetFile, appAssets, headTags, shareImageUrls, typeOf, } from "./appAssets.js";
@@ -264,6 +264,8 @@ function devPolicy() {
264
264
  return contentSecurityPolicy;
265
265
  return devContentSecurityPolicy(contentSecurityPolicy, { origin: devOrigin || undefined });
266
266
  }
267
+ /** The dev server lock this process holds, once it holds one - see devLock.ts. */
268
+ let devLockDir;
267
269
  /** Resolved from RscKitOptions.openapi; null when off. */
268
270
  let openapi = null;
269
271
  let foundAssets = {
@@ -8063,7 +8065,27 @@ export function rscKit(options = {}) {
8063
8065
  nitro.options.plugins = [...(nitro.options.plugins ?? []), "#rsc-kit/startup"];
8064
8066
  },
8065
8067
  },
8066
- config(_config, env) {
8068
+ async config(_config, env) {
8069
+ // One dev server per app - see devLock.ts. Here, the first hook, and
8070
+ // not in configureServer: waiting there, other plugins carried on
8071
+ // around it - Nitro imported the entries before plugin-rsc had its
8072
+ // server, and the failed import answered every request with a 500
8073
+ // once this one started. Before any environment exists nothing runs.
8074
+ if (env.command === "serve" && !env.isPreview) {
8075
+ const lockDir = join(projectRoot, "node_modules", ".vite");
8076
+ const holder = claimDevServer(lockDir);
8077
+ if (holder) {
8078
+ log(secondDevServerMessage(projectRoot, holder).replace(/^\[rsc-kit\] /, ""));
8079
+ await waitForDevServer(lockDir);
8080
+ log("the other dev server stopped — starting this one");
8081
+ }
8082
+ // Released when the process exits, never when its http server
8083
+ // closes: a restart opens the new server before closing the old.
8084
+ if (!devLockDir) {
8085
+ devLockDir = lockDir;
8086
+ process.once("exit", () => releaseDevServer(lockDir));
8087
+ }
8088
+ }
8067
8089
  // Here and not only in configResolved: the entries below are written
8068
8090
  // in this hook, and the 404's policy in them is dev's or the build's.
8069
8091
  devServer = env.command === "serve";
@@ -8403,18 +8425,11 @@ export function rscKit(options = {}) {
8403
8425
  // Swapping the plugins in the app's config is not a fix: Nitro then loads
8404
8426
  // .env too late for the app's first request.
8405
8427
  configureServer: { order: "pre", handler(server) {
8406
- // One dev server per app - see devLock.ts. Released when the process
8407
- // exits, never when its http server closes: a restart opens the new
8408
- // server in this process before closing the old one.
8409
- const cacheDir = server.config.cacheDir;
8410
- const holder = claimDevServer(cacheDir);
8411
- if (holder)
8412
- throw new Error(secondDevServerMessage(projectRoot, holder));
8413
- process.once("exit", () => releaseDevServer(cacheDir));
8428
+ // Where this one listens, for the message a second one prints.
8414
8429
  server.httpServer?.once("listening", () => {
8415
8430
  const url = server.resolvedUrls?.local?.[0];
8416
- if (url)
8417
- recordDevServerUrl(cacheDir, url.replace(/\/$/, ""));
8431
+ if (url && devLockDir)
8432
+ recordDevServerUrl(devLockDir, url.replace(/\/$/, ""));
8418
8433
  });
8419
8434
  // The rules an agent follows here say which rsc-kit wrote them. One
8420
8435
  // line when they are older than the rsc-kit running - never a rewrite: