diff --git a/api/package.json b/api/package.json index 3fe05d7..ea22ca3 100644 --- a/api/package.json +++ b/api/package.json @@ -15,7 +15,7 @@ "check": "pnpm run lexicons:check && tsc --noEmit" }, "dependencies": { - "@atmo-dev/contrail": "^0.19.0" + "@atmo-dev/contrail": "^0.21.2" }, "devDependencies": { "@atcute/lex-cli": "^3.2.1", diff --git a/package.json b/package.json index cee7e83..86ffd7f 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@atcute/client": "^5.1.1", "@atcute/lexicons": "^2.0.3", "@atcute/password-session": "^1.0.2", - "@atmo-dev/contrail": "^0.19.0", + "@atmo-dev/contrail": "^0.21.2", "@earendil-works/pi-coding-agent": "^0.84.2", "@ethercorps/sveltekit-og": "^4.3.0", "@foxui/core": "^0.9.1", diff --git a/patches/@atmo-dev__contrail@0.21.2.patch b/patches/@atmo-dev__contrail@0.21.2.patch new file mode 100644 index 0000000..5b88b37 --- /dev/null +++ b/patches/@atmo-dev__contrail@0.21.2.patch @@ -0,0 +1,30 @@ +diff --git a/dist/chunk-QSFEXFPO.js b/dist/chunk-QSFEXFPO.js +index fbea95c3bb279a5d7c4fb1e867f300aece87ee2f..1cbe0c2a714292cb7a8f6742f200072555f5332a 100644 +--- a/dist/chunk-QSFEXFPO.js ++++ b/dist/chunk-QSFEXFPO.js +@@ -5293,11 +5293,20 @@ function admissionFilteredCount(dropped) { + function runtimeCpuUsage() { + const runtimeProcess = globalThis.process; + if (!runtimeProcess?.cpuUsage) return null; +- const start = runtimeProcess.cpuUsage(); +- return () => { +- const elapsed = runtimeProcess.cpuUsage(start); +- return Math.round((elapsed.user + elapsed.system) / 100) / 10; +- }; ++ try { ++ const start = runtimeProcess.cpuUsage(); ++ return () => { ++ try { ++ const elapsed = runtimeProcess.cpuUsage(start); ++ return Math.round((elapsed.user + elapsed.system) / 100) / 10; ++ } catch { ++ return null; ++ } ++ }; ++ } catch { ++ // Cloudflare Workers exposes process.cpuUsage as an unimplemented stub. ++ return null; ++ } + } + async function runIngestCycle(db, config, budgetInput = DEFAULT_SCHEDULED_INGEST_BUDGET, state) { + const log = getLogger2(config); diff --git a/patches/partysocket@1.3.0.patch b/patches/partysocket@1.3.0.patch new file mode 100644 index 0000000..be96759 --- /dev/null +++ b/patches/partysocket@1.3.0.patch @@ -0,0 +1,58 @@ +diff --git a/dist/ws.cjs b/dist/ws.cjs +index 56ecd6b29236431ea03d46666b4eeb8212002e4e..5398f6c6ca2edf241648d8b395212352dd2b4b85 100644 +--- a/dist/ws.cjs ++++ b/dist/ws.cjs +@@ -40,11 +40,23 @@ const Events = { + function assert(condition, msg) { + if (!condition) throw new Error(msg); + } ++function cloneMessageEvent(e) { ++ // Cloudflare Workers rejects a WebSocket-valued MessageEvent.source when ++ // another MessageEvent is used directly as the initializer. PartySocket only ++ // needs to preserve the payload metadata when redispatching this event. ++ return new MessageEvent(e.type, { ++ data: e.data, ++ origin: e.origin, ++ lastEventId: e.lastEventId, ++ ports: e.ports ++ }); ++} + function cloneEventBrowser(e) { ++ if ("data" in e) return cloneMessageEvent(e); + return new e.constructor(e.type, e); + } + function cloneEventNode(e) { +- if ("data" in e) return new MessageEvent(e.type, e); ++ if ("data" in e) return cloneMessageEvent(e); + if ("code" in e || "reason" in e) + return new CloseEvent(e.code || 1999, e.reason || "unknown reason", e); + if ("error" in e) return new ErrorEvent(e.error, e); +diff --git a/dist/ws.js b/dist/ws.js +index 0e844fd074243961c00db049f340f788303da99f..e33544d2a53b0a7ad6f1a4c907eca088d6b5178f 100644 +--- a/dist/ws.js ++++ b/dist/ws.js +@@ -36,11 +36,23 @@ const Events = { + function assert(condition, msg) { + if (!condition) throw new Error(msg); + } ++function cloneMessageEvent(e) { ++ // Cloudflare Workers rejects a WebSocket-valued MessageEvent.source when ++ // another MessageEvent is used directly as the initializer. PartySocket only ++ // needs to preserve the payload metadata when redispatching this event. ++ return new MessageEvent(e.type, { ++ data: e.data, ++ origin: e.origin, ++ lastEventId: e.lastEventId, ++ ports: e.ports ++ }); ++} + function cloneEventBrowser(e) { ++ if ("data" in e) return cloneMessageEvent(e); + return new e.constructor(e.type, e); + } + function cloneEventNode(e) { +- if ("data" in e) return new MessageEvent(e.type, e); ++ if ("data" in e) return cloneMessageEvent(e); + if ("code" in e || "reason" in e) + return new CloseEvent(e.code || 1999, e.reason || "unknown reason", e); + if ("error" in e) return new ErrorEvent(e.error, e); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e779962..6f05d65 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,14 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + '@atmo-dev/contrail@0.21.2': + hash: 59e0b0304fd1760543057612459d22dda1ca65d7f347e0c4f3fea6bb592bb0a0 + path: patches/@atmo-dev__contrail@0.21.2.patch + partysocket@1.3.0: + hash: 7f929c21cc06e713191f2e26002ad3902b37b0548de7c5d4a4d4c31504625f08 + path: patches/partysocket@1.3.0.patch + importers: .: @@ -21,8 +29,8 @@ importers: specifier: ^1.0.2 version: 1.0.2(@atcute/identity@2.0.2(@atcute/lexicons@2.0.3)(typescript@6.0.3))(@atcute/lexicons@2.0.3)(typescript@6.0.3) '@atmo-dev/contrail': - specifier: ^0.19.0 - version: 0.19.0(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1)) + specifier: ^0.21.2 + version: 0.21.2(patch_hash=59e0b0304fd1760543057612459d22dda1ca65d7f347e0c4f3fea6bb592bb0a0)(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1)) '@earendil-works/pi-coding-agent': specifier: ^0.84.2 version: 0.84.2(ws@8.21.3) @@ -148,8 +156,8 @@ importers: api: dependencies: '@atmo-dev/contrail': - specifier: ^0.19.0 - version: 0.19.0(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1)) + specifier: ^0.21.2 + version: 0.21.2(patch_hash=59e0b0304fd1760543057612459d22dda1ca65d7f347e0c4f3fea6bb592bb0a0)(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1)) devDependencies: '@atcute/lex-cli': specifier: ^3.2.1 @@ -330,8 +338,8 @@ packages: peerDependencies: '@atcute/lexicons': ^2.0.0 - '@atmo-dev/contrail@0.19.0': - resolution: {integrity: sha512-4eP4uHcX2r5f0/fQY+NvsiIHBz4BGwOlAWJ0GxMFW3Sr0sSVZm1Y1hC80S+BK8XL/Iv4JIC9RwbeawwZ7wg8IA==} + '@atmo-dev/contrail@0.21.2': + resolution: {integrity: sha512-we+qZZSHHwBa/FpA1O0G4eYMY6fo9ZHGOEBflkJUXsZRXSaB9UC88WhsaoVTKIbYmXyrGWkZjIGPUcmd1rlRTA==} hasBin: true peerDependencies: pg: ^8.0.0 @@ -3422,7 +3430,7 @@ snapshots: '@atcute/lexicons': 2.0.3 '@mary-ext/event-iterator': 1.0.0 '@mary-ext/simple-event-emitter': 1.0.2 - partysocket: 1.3.0 + partysocket: 1.3.0(patch_hash=7f929c21cc06e713191f2e26002ad3902b37b0548de7c5d4a4d4c31504625f08) type-fest: 4.41.0 valibot: 1.4.2(typescript@6.0.3) transitivePeerDependencies: @@ -3594,7 +3602,7 @@ snapshots: - '@atcute/cid' - typescript - '@atmo-dev/contrail@0.19.0(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1))': + '@atmo-dev/contrail@0.21.2(patch_hash=59e0b0304fd1760543057612459d22dda1ca65d7f347e0c4f3fea6bb592bb0a0)(prettier@3.9.6)(typescript@6.0.3)(wrangler@4.123.0(@cloudflare/workers-types@5.20260815.1))': dependencies: '@atcute/atproto': 4.0.4(@atcute/lexicons@2.0.3) '@atcute/cbor': 2.3.6(@atcute/cid@2.4.2) @@ -3608,6 +3616,7 @@ snapshots: '@atcute/lexicons': 2.0.3 '@atcute/oauth-types': 1.0.1(typescript@6.0.3) '@atcute/tid': 1.1.4 + '@atcute/uint8array': 1.1.5 '@atcute/xrpc-server': 2.0.2(@atcute/cid@2.4.2)(@atcute/lexicons@2.0.3)(typescript@6.0.3) cac: 7.0.0 hono: 4.13.2 @@ -5860,7 +5869,7 @@ snapshots: partial-json@0.1.7: {} - partysocket@1.3.0: + partysocket@1.3.0(patch_hash=7f929c21cc06e713191f2e26002ad3902b37b0548de7c5d4a4d4c31504625f08): dependencies: event-target-polyfill: 0.0.4 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index a44f21d..16cc374 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,3 +4,7 @@ packages: allowBuilds: esbuild: true workerd: true + +patchedDependencies: + '@atmo-dev/contrail@0.21.2': patches/@atmo-dev__contrail@0.21.2.patch + partysocket@1.3.0: patches/partysocket@1.3.0.patch