syumai / workers

Go package to run an HTTP server on Cloudflare Workers.
MIT License
710 stars 41 forks source link

Error: write EPIPE when using wrangler dev to run cloudflare worker using itty-router #59

Open zztkm opened 1 year ago

zztkm commented 1 year ago

Issue

When I do what the quick start says, I get the following error when I run make dev

My Environment

Error

āÆ make dev
wrangler dev
 ā›…ļø wrangler 3.0.1
------------------
wrangler dev now uses local mode by default, powered by šŸ”„ Miniflare and šŸ‘· workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Running custom build: make build
make[1]: Entering directory '/home/zztkm/dev/github.com/pistachiostudio/hello-api'
go run github.com/syumai/workers/cmd/workers-assets-gen@latest
tinygo build -o ./build/app.wasm -target wasm ./...
make[1]: Leaving directory '/home/zztkm/dev/github.com/pistachiostudio/hello-api'
āŽ” Starting local server...
ā•­ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•®
ā”‚ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                                           ā”‚
ā•°ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•Æ
/usr/local/lib/node_modules/wrangler/wrangler-dist/cli.js:30632
            throw a;
            ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:917:11)
    at Socket._write (node:net:929:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Runtime.updateConfig (/usr/local/lib/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:5120:26)
    at async #assembleAndUpdateConfig (/usr/local/lib/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:9130:23)
    at async #init (/usr/local/lib/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:8894:5)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v18.12.1
make: *** [Makefile:3: dev] Error 7

Solution

I was able to solve the problem by installing libc++1.

apt install libc++1

refs: https://stackoverflow.com/questions/76281931/error-write-epipe-when-using-wrangler-dev-to-run-cloudflare-worker-using-itty-r

syumai commented 1 year ago

This seems to be an issue with Wrangler and the workerd, but I'll leave this issue open for now as it may be helpful to the users of syumai/workers. Thanks @zztkm!

wdssmq commented 1 year ago

I encountered the same issue on Ubuntu 20.04 / WSL2 / Node.js v18.16.1. Trying to install libc++1 did not solve it...

/home/wdssmq/.local/share/pnpm/global/5/.pnpm/wrangler@3.1.1/node_modules/wrangler/wrangler-dist/cli.js:30632
            throw a;
            ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:930:11)
    at Socket._write (node:net:942:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Runtime.updateConfig (/home/wdssmq/.local/share/pnpm/global/5/.pnpm/miniflare@3.0.2/node_modules/miniflare/dist/src/index.js:5125:26)
    at async #assembleAndUpdateConfig (/home/wdssmq/.local/share/pnpm/global/5/.pnpm/miniflare@3.0.2/node_modules/miniflare/dist/src/index.js:9140:23)
    at async #init (/home/wdssmq/.local/share/pnpm/global/5/.pnpm/miniflare@3.0.2/node_modules/miniflare/dist/src/index.js:8902:5)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v18.16.1
zztkm commented 1 year ago

@wdssmq The cause is not known, but updating to Ubuntu 22.04 may solve the problem...