From 32218ac5286a51c79d7e06fcefc7e3e8b439adc8 Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Fri, 3 Jul 2026 23:05:23 -0700 Subject: [PATCH] chore(selfhost): remove orphaned register-selfhost.mjs Docker entrypoint script Its own header claimed it was used as the Docker entry via `node --import ./scripts/register-selfhost.mjs dist/server.mjs`, but the Dockerfile CMD has no --import flag, and no other script/doc/workflow step ever invoked it that way -- only a stale CI path filter referenced the file's existence, not its runtime use. Verified empirically rather than just by inspection: rebuilt the self-host bundle with `node scripts/build-selfhost.mjs --all` (the exact mode the Dockerfile's own build step uses) and grepped the resulting fully-bundled dist/server.mjs for any `cloudflare:` string -- zero matches. The build-time esbuild stub plugin (cloudflare:workers / @cloudflare/puppeteer / agents/mcp) already eliminates every reachable cloudflare:* specifier from the actual Docker image, including transitive node_modules internals, so the runtime --import hook this script provided was fully redundant. Removes the script and its stale reference in .github/workflows/selfhost.yml's path filters. --- .github/workflows/selfhost.yml | 2 -- scripts/register-selfhost.mjs | 29 ----------------------------- 2 files changed, 31 deletions(-) delete mode 100644 scripts/register-selfhost.mjs diff --git a/.github/workflows/selfhost.yml b/.github/workflows/selfhost.yml index e732a99594..b26844e47e 100644 --- a/.github/workflows/selfhost.yml +++ b/.github/workflows/selfhost.yml @@ -13,7 +13,6 @@ on: - "src/server.ts" - "scripts/build-selfhost.mjs" - "scripts/validate-selfhost-sourcemap.mjs" - - "scripts/register-selfhost.mjs" - "Dockerfile" - "docker-compose.yml" - "migrations/**" @@ -26,7 +25,6 @@ on: - "src/server.ts" - "scripts/build-selfhost.mjs" - "scripts/validate-selfhost-sourcemap.mjs" - - "scripts/register-selfhost.mjs" - "Dockerfile" - "docker-compose.yml" - "migrations/**" diff --git a/scripts/register-selfhost.mjs b/scripts/register-selfhost.mjs deleted file mode 100644 index a04c36e2a2..0000000000 --- a/scripts/register-selfhost.mjs +++ /dev/null @@ -1,29 +0,0 @@ -// Self-host module-resolution hooks (run before the app loads). Any `cloudflare:*` import — from gittensory's -// source OR a transitive dep (@cloudflare/puppeteer, the agents SDK / partyserver) — resolves to an in-memory -// stub. These bindings are never USED on self-host (BROWSER/RATE_LIMITER/email absent → the code degrades -// before touching them); the stub only makes the import + any `extends`/named import resolve so Node can load -// the graph. Used as the Docker entry: `node --import ./scripts/register-selfhost.mjs dist/server.mjs`. -import { registerHooks } from "node:module"; - -const STUB_SOURCE = [ - "export class DurableObject { constructor(ctx, env) { this.ctx = ctx; this.env = env; } }", - "export class WorkerEntrypoint { constructor(ctx, env) { this.ctx = ctx; this.env = env; } }", - "export class WorkflowEntrypoint { constructor(ctx, env) { this.ctx = ctx; this.env = env; } }", - "export class RpcTarget {}", - "export class EmailMessage { constructor(from, to, raw) { this.from = from; this.to = to; this.raw = raw; } }", - "export const env = {};", - "export const WorkerVersionMetadata = {};", - "export function connect() { throw new Error('cloudflare:sockets is unavailable on the self-host runtime'); }", - "export default {};", -].join("\n"); - -registerHooks({ - resolve(specifier, context, nextResolve) { - if (specifier.startsWith("cloudflare:")) return { url: `cfstub:${specifier}`, shortCircuit: true }; - return nextResolve(specifier, context); - }, - load(url, context, nextLoad) { - if (url.startsWith("cfstub:")) return { format: "module", shortCircuit: true, source: STUB_SOURCE }; - return nextLoad(url, context); - }, -});