diff --git a/.changeset/windows-shared-memory-type.md b/.changeset/windows-shared-memory-type.md new file mode 100644 index 0000000000..6b50888b59 --- /dev/null +++ b/.changeset/windows-shared-memory-type.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Fix embedded PostgreSQL failing to start on Windows after the mmap shared-memory default. +category: fix +dev: "shared_memory_type=mmap (default added 2026-07-16 for SysV shm exhaustion) is rejected on Windows, where the only valid value is windows — every Windows embedded start died with FATAL invalid value for parameter before the port opened, failing the v0.70.0/v0.70.1 Windows release smoke. Default flags are now platform-aware via defaultEmbeddedPostgresFlagsFor: empty on win32 (Windows needs no override; SysV exhaustion cannot occur there), mmap elsewhere." diff --git a/packages/core/src/__tests__/postgres/embedded-lifecycle.test.ts b/packages/core/src/__tests__/postgres/embedded-lifecycle.test.ts index 69583f020f..9412f1e938 100644 --- a/packages/core/src/__tests__/postgres/embedded-lifecycle.test.ts +++ b/packages/core/src/__tests__/postgres/embedded-lifecycle.test.ts @@ -34,6 +34,7 @@ import { EmbeddedStartTimeoutError, DEFAULT_START_TIMEOUT_MS, DEFAULT_EMBEDDED_POSTGRES_FLAGS, + defaultEmbeddedPostgresFlagsFor, isDataDirInitialized, isWindowsElevatedAdmin, normalizeMacosEmbeddedPostgresDylibSymlinks, @@ -1124,6 +1125,24 @@ describe("embedded-lifecycle: shared-memory-safe postgres flags", () => { __setEmbeddedPostgresCtorForTests(RecordingEmbeddedPostgres as never); } + /* + * FNXC:PostgresEmbedded 2026-07-17-19:20: + * `shared_memory_type=mmap` is rejected by PostgreSQL on Windows (only value: + * `windows`) with a FATAL before the port opens — the mmap default broke every + * Windows embedded start and the v0.70.0/v0.70.1 Windows release smoke. The + * default flag set must stay platform-aware: no shared_memory_type override on + * win32, mmap everywhere else. + */ + it.each(["win32", "darwin", "linux"] as const)("default flags are valid for %s", (platform) => { + const flags = defaultEmbeddedPostgresFlagsFor(platform); + if (platform === "win32") { + expect(flags).toEqual([]); + } else { + expect(flags).toEqual(["-c", "shared_memory_type=mmap"]); + } + expect(flags.join(" ")).not.toMatch(platform === "win32" ? /shared_memory_type/ : /shared_memory_type=(windows|sysv)/); + }); + it.each([ ["omitted", undefined, [...DEFAULT_EMBEDDED_POSTGRES_FLAGS]], ["empty", [], [...DEFAULT_EMBEDDED_POSTGRES_FLAGS]], diff --git a/packages/core/src/postgres/embedded-lifecycle.ts b/packages/core/src/postgres/embedded-lifecycle.ts index f81083469a..40a2ee05a8 100644 --- a/packages/core/src/postgres/embedded-lifecycle.ts +++ b/packages/core/src/postgres/embedded-lifecycle.ts @@ -630,8 +630,21 @@ export const DEFAULT_EMBEDDED_DATABASE = "fusion"; * so the zero-config cluster has been boot-smoke tested with a 64MB /dev/shm * lower bound. Defaults precede caller flags because PostgreSQL applies repeated * `-c key=value` settings last-wins, preserving an operator's explicit override. + * + * FNXC:PostgresEmbedded 2026-07-17-19:20: + * `mmap` is only valid on POSIX platforms. On Windows PostgreSQL accepts a single + * value, `windows`, and rejects `mmap` with FATAL `invalid value for parameter + * "shared_memory_type"` before opening the port — this broke every Windows + * embedded start (and the v0.70.0/v0.70.1 Windows release smoke) the day the + * mmap default landed. Windows needs no override at all, so the default flag set + * is empty there; the SysV exhaustion the mmap default fixes cannot occur on + * Windows anyway. */ -export const DEFAULT_EMBEDDED_POSTGRES_FLAGS = ["-c", "shared_memory_type=mmap"] as const; +export function defaultEmbeddedPostgresFlagsFor(platform: NodeJS.Platform): readonly string[] { + return platform === "win32" ? [] : ["-c", "shared_memory_type=mmap"]; +} + +export const DEFAULT_EMBEDDED_POSTGRES_FLAGS = defaultEmbeddedPostgresFlagsFor(process.platform); /** * FNXC:PostgresEmbedded 2026-06-24-09:05: