@powerhousedao/switchboard 6.2.3-dev.71 → 6.2.3-dev.73
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/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +29 -0
- package/dist/index.mjs +1 -1
- package/dist/plugins/attachments.mjs +3 -3
- package/dist/{server-Be1vmpxu.mjs → server-CrWPtMG6.mjs} +63 -5
- package/dist/server-CrWPtMG6.mjs.map +1 -0
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +3 -3
- package/package.json +16 -16
- package/test/attachments/routes.test.ts +26 -11
- package/test/store-lock.test.ts +65 -0
- package/dist/server-Be1vmpxu.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## 6.2.3-dev.73 (2026-10-23)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **builder-tools:** the worker-safe vendor check parses imports, so import-like text in strings and comments no longer counts ([9d3e167f4b](https://github.com/powerhouse-inc/powerhouse/commit/9d3e167f4b))
|
|
6
|
+
- **reactor-browser,connect,reactor-monitor:** the worker reactor loads a registry package's module graph, and packages added or updated after boot ([5348ffa792](https://github.com/powerhouse-inc/powerhouse/commit/5348ffa792))
|
|
7
|
+
- **powerhouse-vetra-packages:** the document-model editor writes nothing on open unless the model is blank ([f5dc33dd0a](https://github.com/powerhouse-inc/powerhouse/commit/f5dc33dd0a))
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- acaldas
|
|
12
|
+
|
|
13
|
+
## 6.2.3-dev.72 (2026-10-23)
|
|
14
|
+
|
|
15
|
+
### 🚀 Features
|
|
16
|
+
|
|
17
|
+
- **shared,connect,codegen:** ph init and ph migrate give a project the router as a peer at connect's version, and the host stylesheet shows light and dark tokens ([0829546eaf](https://github.com/powerhouse-inc/powerhouse/commit/0829546eaf))
|
|
18
|
+
|
|
19
|
+
### 🩹 Fixes
|
|
20
|
+
|
|
21
|
+
- **switchboard:** one process per PGlite store ([a2283f4a52](https://github.com/powerhouse-inc/powerhouse/commit/a2283f4a52))
|
|
22
|
+
- **reactor-attachments,switchboard:** an empty file is a valid attachment ([223d231756](https://github.com/powerhouse-inc/powerhouse/commit/223d231756))
|
|
23
|
+
|
|
24
|
+
### ❤️ Thank You
|
|
25
|
+
|
|
26
|
+
- acaldas
|
|
27
|
+
- Claude Opus 5.5
|
|
28
|
+
- Wouter Kampmann
|
|
29
|
+
|
|
1
30
|
## 6.2.3-dev.71 (2026-10-22)
|
|
2
31
|
|
|
3
32
|
### 🚀 Features
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c9eef974-47b1-5e45-aad6-5ebb1885b76a")}catch(e){}}();
|
|
4
|
-
import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-
|
|
4
|
+
import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-CrWPtMG6.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
7
7
|
import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-
|
|
1
|
+
import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-CrWPtMG6.mjs";
|
|
2
2
|
export { attachmentsPlugin, attachmentsPlugin as default, attachmentsPluginConfigSchema };
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
4
|
-
//# debugId=
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="383f9b00-d2f6-5824-a01a-6361cbd9470a")}catch(e){}}();
|
|
4
|
+
//# debugId=383f9b00-d2f6-5824-a01a-6361cbd9470a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="290090f1-e3b3-5338-a8cc-2072903fbb2a")}catch(e){}}();
|
|
3
3
|
import { _ as triggerFatalShutdown, a as workflowsPlugin, c as WORKFLOW_TELEMETRY_SCOPE, d as isWorkflowSingletonConflict, f as modelManifestSource, g as installFatalErrorShutdown, h as workflowSingletonLossHandler, l as assertWorkflowPackageLoadable, m as retryWorkflowSingleton, p as resolveWorkflowsEnabled, s as WORKFLOW_PACKAGE_NAME, u as composeWorkflowRuntime } from "./workflows-fsBcElEi.mjs";
|
|
4
4
|
import { i as startPrivacy, r as resolvePrivacy, t as privacyPlugin } from "./privacy-BsFl7GzK.mjs";
|
|
5
5
|
import { t as mcpPlugin } from "./mcp-SsBK14Jm.mjs";
|
|
@@ -11,7 +11,7 @@ import * as Sentry from "@sentry/node";
|
|
|
11
11
|
import { childLogger, setLogLevel } from "document-model";
|
|
12
12
|
import dotenv from "dotenv";
|
|
13
13
|
import { getConfig } from "@powerhousedao/config/node";
|
|
14
|
-
import { existsSync, promises, realpathSync } from "node:fs";
|
|
14
|
+
import fs, { existsSync, promises, realpathSync } from "node:fs";
|
|
15
15
|
import path, { resolve } from "node:path";
|
|
16
16
|
import { createDurableNodeFs, preparePgliteDataDir, removeStalePgliteFiles, resolvePgliteFsync, syncTree } from "@powerhousedao/reactor-api/pglite-node";
|
|
17
17
|
import { ChannelScheme, DriveCollectionId, EventBus, HardenedPGliteDialect, IN_MEMORY_PGLITE_STORAGE_FACTS, PGLITE_PATH_STORAGE_FACTS, POSTGRES_STORAGE_FACTS, REACTOR_SCHEMA, ReactorBuilder, ReactorClientBuilder, UnsupportedStoredProtocolError, createHybridProjectionCoordinatorFactory, instrumentPgPool, parseDriveUrl, supportsLiveReadModelRegistration } from "@powerhousedao/reactor";
|
|
@@ -259,7 +259,7 @@ function parseReserveOptions(input) {
|
|
|
259
259
|
if (extension !== null && typeof extension !== "string") return null;
|
|
260
260
|
if (obj.clientHash !== void 0) {
|
|
261
261
|
if (typeof obj.clientHash !== "string" || !HASH_PATTERN.test(obj.clientHash)) return null;
|
|
262
|
-
if (typeof obj.sizeBytes !== "number" || !Number.
|
|
262
|
+
if (typeof obj.sizeBytes !== "number" || !Number.isSafeInteger(obj.sizeBytes) || obj.sizeBytes < 0) return null;
|
|
263
263
|
return {
|
|
264
264
|
mimeType,
|
|
265
265
|
fileName,
|
|
@@ -1719,6 +1719,63 @@ var StoredDocumentsRefusedError = class extends Error {
|
|
|
1719
1719
|
}
|
|
1720
1720
|
};
|
|
1721
1721
|
//#endregion
|
|
1722
|
+
//#region src/store-lock.mts
|
|
1723
|
+
var StoreInUseError = class extends Error {
|
|
1724
|
+
dir;
|
|
1725
|
+
owner;
|
|
1726
|
+
constructor(dir, owner) {
|
|
1727
|
+
super(`The PGlite store ${dir} is in use by another process (pid ${owner.pid}, since ${owner.startedAt}: ${owner.command}). Two processes on one PGlite store corrupt it. Stop that process first, or point this one at a different store.`);
|
|
1728
|
+
this.dir = dir;
|
|
1729
|
+
this.owner = owner;
|
|
1730
|
+
this.name = "StoreInUseError";
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
const lockPathOf = (dir) => `${path.resolve(dir)}.lock`;
|
|
1734
|
+
function isAlive(pid) {
|
|
1735
|
+
try {
|
|
1736
|
+
process.kill(pid, 0);
|
|
1737
|
+
return true;
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
return error.code === "EPERM";
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
function readOwner(file) {
|
|
1743
|
+
try {
|
|
1744
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
1745
|
+
} catch {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
const held = /* @__PURE__ */ new Set();
|
|
1750
|
+
let exitHookInstalled = false;
|
|
1751
|
+
function releaseAll() {
|
|
1752
|
+
for (const file of held) if (readOwner(file)?.pid === process.pid) try {
|
|
1753
|
+
fs.rmSync(file);
|
|
1754
|
+
} catch {}
|
|
1755
|
+
held.clear();
|
|
1756
|
+
}
|
|
1757
|
+
/** Take the lock for each store dir, or throw StoreInUseError naming the
|
|
1758
|
+
* live owner. Idempotent within one process. */
|
|
1759
|
+
function acquireStoreLocks(dirs, isPidAlive = isAlive) {
|
|
1760
|
+
const mine = {
|
|
1761
|
+
pid: process.pid,
|
|
1762
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1763
|
+
command: process.argv.slice(1).join(" ").slice(0, 200)
|
|
1764
|
+
};
|
|
1765
|
+
for (const dir of new Set(dirs.map((d) => path.resolve(d)))) {
|
|
1766
|
+
const file = lockPathOf(dir);
|
|
1767
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
1768
|
+
const owner = readOwner(file);
|
|
1769
|
+
if (owner && owner.pid !== process.pid && isPidAlive(owner.pid)) throw new StoreInUseError(dir, owner);
|
|
1770
|
+
fs.writeFileSync(file, `${JSON.stringify(mine)}\n`);
|
|
1771
|
+
held.add(file);
|
|
1772
|
+
}
|
|
1773
|
+
if (!exitHookInstalled) {
|
|
1774
|
+
exitHookInstalled = true;
|
|
1775
|
+
process.on("exit", releaseAll);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
//#endregion
|
|
1722
1779
|
//#region src/server.mts
|
|
1723
1780
|
const defaultLogger = childLogger(["switchboard"]);
|
|
1724
1781
|
const LogLevel = process.env.LOG_LEVEL || "info";
|
|
@@ -1897,6 +1954,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
1897
1954
|
callerReactor: options.reactor !== void 0
|
|
1898
1955
|
});
|
|
1899
1956
|
if (sharedPgliteDir !== null) logger.warn(`The reactor and read-model PGlite stores share one directory (${sharedPgliteDir}): two PGlite instances on one data dir can abort at the first checkpoint and leave the store unopenable. Set PH_REACTOR_DATABASE_URL to a separate directory, or leave dbPath unset for the classic ./.ph/reactor-storage + .ph/read-storage layout.`);
|
|
1957
|
+
if (!PGLITE_IN_MEMORY) acquireStoreLocks(pgliteDirs);
|
|
1900
1958
|
warnIgnoredFlushInterval(logger);
|
|
1901
1959
|
const detectedMajors = await runPglitePreflight({
|
|
1902
1960
|
dirs: pgliteDirs,
|
|
@@ -2520,5 +2578,5 @@ if (import.meta.main) await startSwitchboard({ fatalErrorShutdown: true });
|
|
|
2520
2578
|
//#endregion
|
|
2521
2579
|
export { startSwitchboard as a, attachmentsPlugin as c, initProfilerFromEnv as d, parseForcePgVersion as f, resolvePgliteStorageDirs as i, attachmentsPluginConfigSchema as l, deriveAttachmentServiceConfig as n, StoredDocumentsRefusedError as o, isPortAvailable as r, resolveUnsupportedStoredDocuments as s, createReactorKysely as t, applySwitchboardReactorDefaults as u };
|
|
2522
2580
|
|
|
2523
|
-
//# sourceMappingURL=server-
|
|
2524
|
-
//# debugId=
|
|
2581
|
+
//# sourceMappingURL=server-CrWPtMG6.mjs.map
|
|
2582
|
+
//# debugId=290090f1-e3b3-5338-a8cc-2072903fbb2a
|