sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.45k stars 1.89k forks source link

adapter-cloudflare@^4.0.0 throws ENOENT on alpine linux #12049

Open cocoliliace opened 5 months ago

cocoliliace commented 5 months ago

Describe the bug

Using @sveltejs/adapter-cloudflare@^4.0.0 generates the ENOENT error for the dev and build commands on alpine linux.

This does not happen with version ^3.0.0 on alpine linux, or version ^4.0.0 on other operating systems, or with @sveltejs/adapter-auto@latest on alpine linux.

Reproduction

Repository: https://git.sr.ht/~liliace/bugged-example

This is basically the skeleton project from running pnpm create svelte@latest, then pnpm add -D @sveltejs/adapter-cloudflare and pnpm remove -D @sveltejs/adapter-auto, then replacing the import in svelte.config.js.

I've provided a Containerfile for the alpine linux environment. You can run with docker (docker build -t bugged-example .) or podman (podman build -t bugged-example .) and it will output the error log I pasted below. If you change the first line from node:alpine to node:slim, the build will be successful.

If you keep the Containerfile as is (with node:alpine), and change the version of @sveltejs/adapter-cloudflare to ^3.0.0, or use @sveltejs/adapter-auto, the build will also be successful.

Logs

> test@0.0.1 build
> vite build

vite v5.2.6 building SSR bundle for production...
transforming...
✓ 79 modules transformed.
rendering chunks...
vite v5.2.6 building for production...
transforming...
✓ 61 modules transformed.
rendering chunks...
computing gzip size...
.svelte-kit/output/client/_app/version.json                             0.03 kB │ gzip:  0.05 kB
.svelte-kit/output/client/.vite/manifest.json                           2.25 kB │ gzip:  0.44 kB
.svelte-kit/output/client/_app/immutable/entry/start.CS4bZmir.js        0.07 kB │ gzip:  0.08 kB
.svelte-kit/output/client/_app/immutable/nodes/0.sbPD3avW.js            0.60 kB │ gzip:  0.38 kB
.svelte-kit/output/client/_app/immutable/nodes/2.k97gLCY_.js            0.69 kB │ gzip:  0.45 kB
.svelte-kit/output/client/_app/immutable/nodes/1.TdFCRiDp.js            1.02 kB │ gzip:  0.59 kB
.svelte-kit/output/client/_app/immutable/chunks/scheduler.BvLojk_z.js   2.16 kB │ gzip:  1.02 kB
.svelte-kit/output/client/_app/immutable/chunks/index.fi1e1Nz5.js       5.44 kB │ gzip:  2.31 kB
.svelte-kit/output/client/_app/immutable/entry/app.CAu41V3K.js          6.12 kB │ gzip:  2.47 kB
.svelte-kit/output/client/_app/immutable/chunks/entry.Cjzq2A8j.js      27.35 kB │ gzip: 10.79 kB
✓ built in 908ms

/app/node_modules/wrangler/wrangler-dist/cli.js:29573
            throw a;
            ^
Error: spawn /app/node_modules/@cloudflare/workerd-linux-64/bin/workerd ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /app/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
  path: '/app/node_modules/@cloudflare/workerd-linux-64/bin/workerd',
  spawnargs: [
    'serve',
    '--binary',
    '--experimental',
    '--socket-addr=entry=127.0.0.1:0',
    '--external-addr=loopback=127.0.0.1:44133',
    '--control-fd=3',
    '-'
  ]
}

Node.js v21.7.1
Error: building at STEP "RUN npm run build": while running runtime: exit status 7

System Info

System:
  OS: Linux 6.8 Alpine Linux
  CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
  Memory: 11.00 GB / 15.31 GB
  Container: Yes
  Shell: 5.2.26 - /bin/bash
Binaries:
  Node: 21.7.1 - /usr/bin/node
  npm: 10.5.0 - /usr/bin/npm
  pnpm: 8.15.1 - /usr/bin/pnpm

Severity

blocking an upgrade

Additional Information

No response

Conduitry commented 5 months ago

https://github.com/cloudflare/workerd/issues/286 seems relevant. I don't know whether there's a nice way to make the additions in #11732 degrade gracefully when the native binary fails.