From aacbfafa8e2f287494ec1f3d647295350e8dc911 Mon Sep 17 00:00:00 2001 From: Rhys Sullivan <39114868+RhysSullivan@users.noreply.github.com> Date: Fri, 10 Jul 2026 00:46:07 -0700 Subject: [PATCH] fix(selfhost): ship the platform workerd binary in the docker runtime The workerd npm package's bin/workerd is a Node shim that execs the real binary from the per-platform optional dependency (@cloudflare/workerd--), which package-runtime.ts never copied into the image. Custom app tools failed to sync or invoke with 'workerd is unavailable on this platform'. Copy the platform package alongside the shim, derived per build platform like the libsql native addon. --- .../selfhost-workerd-platform-binary.md | 5 ++++ apps/host-selfhost/scripts/package-runtime.ts | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .changeset/selfhost-workerd-platform-binary.md diff --git a/.changeset/selfhost-workerd-platform-binary.md b/.changeset/selfhost-workerd-platform-binary.md new file mode 100644 index 000000000..eca2e91d1 --- /dev/null +++ b/.changeset/selfhost-workerd-platform-binary.md @@ -0,0 +1,5 @@ +--- +"executor": patch +--- + +Ship the platform workerd binary in the self-host Docker runtime; without it custom app tools failed to sync or invoke with "workerd is unavailable on this platform". diff --git a/apps/host-selfhost/scripts/package-runtime.ts b/apps/host-selfhost/scripts/package-runtime.ts index a5004b89b..9c76b1424 100644 --- a/apps/host-selfhost/scripts/package-runtime.ts +++ b/apps/host-selfhost/scripts/package-runtime.ts @@ -36,6 +36,30 @@ const libsqlNativePackage = (): string => { return `@libsql/${target}`; }; +// The `workerd` package's bin/workerd is a Node shim that execs the real +// binary from the per-platform optional dependency +// (`@cloudflare/workerd--`); without it the runtime throws +// "workerd is unavailable on this platform" on first app-tool bundle or +// invoke. Same per-platform shape as libsql above. +const workerdPlatformPackage = (): string => { + const platformMap: Record = { + "darwin-arm64": "workerd-darwin-arm64", + "darwin-x64": "workerd-darwin-64", + "linux-arm64": "workerd-linux-arm64", + "linux-x64": "workerd-linux-64", + "win32-x64": "workerd-windows-64", + }; + const key = `${process.platform}-${process.arch}`; + const target = platformMap[key]; + if (!target) { + throw new Error( + `package-runtime: no workerd platform package mapped for ${key}. ` + + "Add it to the platform map in apps/host-selfhost/scripts/package-runtime.ts.", + ); + } + return `@cloudflare/${target}`; +}; + const externalPackages = [ "@cloudflare/worker-bundler", "quickjs-emscripten", @@ -46,6 +70,7 @@ const externalPackages = [ "@jitl/quickjs-wasmfile-release-asyncify", "@jitl/quickjs-wasmfile-debug-asyncify", "workerd", + workerdPlatformPackage(), libsqlNativePackage(), ] as const;