cloudflare / cloudflare/workers-sdk
🐛 BUG: `wrangler dev` hangs when run in docker
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 187
Description
### Which Cloudflare product(s) does this pertain to?
Wrangler
### What version(s) of the tool(s) are you using?
3.65.0
### What version of Node are you using?
22.4.1
### What operating system and version are you using?
Linux Debian 12 bookworm
### Describe the Bug
### Observed behavior
I'm using wrangler to run playwright tests locally against a project that will be hosted by Cloudflare Pages. Everything works fine in Mac OS, but when the same code runs in my CI (using docker), wrangler hangs and never returns a response to any requests. Running the same command locally within docker gave me the same result as on my CI.
There is no logs indicating that a request is received by wrangler, and curl just hangs until stopped manually.
In my actual project I use the Playwright official docker image `mcr.microsoft.com/playwright:v1.45.1-jammy`, but I was able to reproduce it with the node image `node:22` without any of my code.
I also tried switching to Cloudflare Workers instead with some dynamic content, but the result was the same.
### Expected behavior
For wrangler to either return a response, or to throw an error if something is missing.
### Steps to reproduce
1. Create a `Dockerfile` locally and copy this content within it.
```docker
FROM node:22
RUN mkdir /dist
RUN echo "Hello world" > /dist/index.html
RUN npm i -g wrangler
ENTRYPOINT [ "wrangler", "pages", "dev", "/dist", "--port", "3000" ]
```
2. Open a terminal, navigate to the folder where the `Dockerfile` is, and create a docker container.
```bash
docker build --tag wrangler_reproduction .
docker run --name wrangler wrangler_reproduction
```
3. Open a new tab in the same folder and open a shell in the docker container.
```bash
docker exec -it wrangler /bin/bash
# In the docker shell
curl -v http://localhost:3000/index.html
```
4. In my case, the curl request just hangs. You can further inspect the wrangler logs to see that there's nothing of interest within it. My own log has messages around missing `.env` and `.dev.vars` file, but they're debug messages and adding empty ones didn't help.
```bash
more /root/.config/.wrangler/logs/ # press tab to auto-complete to the latest log file
```
### Please provide a link to a minimal reproduction
_No response_
### Please provide any relevant error logs
```
--- 2024-07-17T21:20:13.038Z debug
🪵 Writing logs to "/root/.config/.wrangler/logs/wrangler-2024-07-17_21-20-12_835.log"
---
--- 2024-07-17T21:20:13.038Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
at Object.openSync (node:fs:562:18)
at Object.readFileSync (node:fs:446:35)
at tryLoadDotEnv (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:159217:72)
at loadDotEnv (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:159226:12)
at /usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:202152:20
at /usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:165885:16
at maybeAsyncResult (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:164106:44)
at /usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:165884:14
at /usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:164093:22
at Array.reduce () {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '.env'
}
---
--- 2024-07-17T21:20:14.642Z log
⛅️ wrangler 3.65.0
-------------------
---
--- 2024-07-17T21:20:14.643Z debug
No experimental flag store instantiated
---
--- 2024-07-17T21:20:14.643Z debug
Attempted to use flag "JSON_CONFIG_FILE" which has not been instantiated
---
--- 2024-07-17T21:20:14.719Z warn
▲ [WARNING] No compatibility_date was specified. Using today's date: 2024-07-17.
❯❯ Add one to your wrangler.toml file: compatibility_date = "2024-07-17", or
❯❯ Pass it in your terminal: wrangler pages dev [] --compatibility-date=2024-07-17
See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.
---
--- 2024-07-17T21:20:14.720Z log
No Functions. Shimming...
---
--- 2024-07-17T21:20:14.743Z debug
Failed to load .env file "/.dev.vars": Error: ENOENT: no such file or directory, open '/.dev.vars'
at Object.openSync (node:fs:562:18)
at Object.readFileSync (node:fs:446:35)
at tryLoadDotEnv (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:159217:72)
at loadDotEnv (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:159226:12)
at getVarsForDev (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:198833:18)
at getBindings (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:208793:10)
at getResolvedBindings (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:208663:20)
at getBindingsAndAssetPaths (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:208693:15)
at getDevReactElement (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:208326:40)
at startDev (/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:208393:60) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/.dev.vars'
}
---
--- 2024-07-17T21:20:14.745Z debug
No folder available to cache configuration
---
--- 2024-07-17T21:20:14.748Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}}.
---
--- 2024-07-17T21:20:14.827Z log
⎔ Starting local server...
---
--- 2024-07-17T21:20:15.123Z log
⎔ Reloading local server...
---
--- 2024-07-17T21:20:15.254Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run pages dev","properties":{}}.
---
```
Contributor guide
Assessment
This issue has not been assessed yet.