Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@counterscale/server#build fails: EPIPE write error #155

Open
shazow opened this issue Feb 4, 2025 · 7 comments
Open

@counterscale/server#build fails: EPIPE write error #155

shazow opened this issue Feb 4, 2025 · 7 comments

Comments

@shazow
Copy link

shazow commented Feb 4, 2025

Heya, finally got around to trying counterscale (sorry it took so long 😅), followed the instructions on the README (using the latest main branch) but I'm getting an error on the npx turbo deploy step (note I'm running on NixOS, but I don't think it should matter).

Sounds like a miniflare socket write error maybe? I'm not familiar enough with the inner workings yet to debug.

Any idea what might cause this? Full output below:

$ npx turbo deploy
turbo 2.3.3

• Packages in scope: @counterscale/server, @counterscale/tracker
• Running deploy in 2 packages
• Remote caching disabled
@counterscale/tracker:build: cache hit (outputs already on disk), replaying logs a36201ebbe3f3fd1
@counterscale/tracker:build:
@counterscale/tracker:build:
@counterscale/tracker:build: > @counterscale/[email protected] build
@counterscale/tracker:build: > vite build -c vite.loader.config.ts && vite build -c vite.module.config.ts
@counterscale/tracker:build:
vite v6.0.4 building for production...
✓ 6 modules transformed.
dist/loader/tracker.js  2.92 kB │ gzip: 1.26 kB
dist/loader/tracker.umd.cjs  2.39 kB │ gzip: 1.17 kB
@counterscale/tracker:build: ✓ built in 103ms
@counterscale/tracker:build: vite v6.0.4 building for production...
✓ 5 modules transformed.

@counterscale/tracker:build: [vite:dts] Start generate declaration files...
computing gzip size (0)...[vite:dts] Outside emitted: /home/shazow/local/src/github.com/benvinegar/counterscale/packages/tracker/dist/vitest.config.d.ts
dist/module/index.js  2.55 kB │ gzip: 1.10 kB
@counterscale/tracker:build: [vite:dts] Declaration files built in 1355ms.
@counterscale/tracker:build:
dist/module/index.umd.cjs  2.32 kB │ gzip: 1.12 kB
@counterscale/tracker:build: ✓ built in 1.44s

@counterscale/server:copytracker: cache hit (outputs already on disk), replaying logs 45cd4ba550188b05
@counterscale/server:copytracker:
@counterscale/server:copytracker:
@counterscale/server:copytracker: > @counterscale/[email protected] copytracker
@counterscale/server:copytracker: > cp ../tracker/dist/loader/tracker.js ./public/tracker.js
@counterscale/server:copytracker:

@counterscale/server:build: cache miss, executing 8848f14e9cb9b01a
@counterscale/server:build:
@counterscale/server:build:
@counterscale/server:build: > @counterscale/[email protected] build
@counterscale/server:build: > react-router build
@counterscale/server:build:
Error: write EPIPE
@counterscale/server:build:     at afterWriteDispatched (node:internal/stream_base_commons:159:15)
@counterscale/server:build:     at writeGeneric (node:internal/stream_base_commons:150:3)
@counterscale/server:build:     at Socket._writeGeneric (node:net:964:11)
@counterscale/server:build:     at Socket._write (node:net:976:8)
@counterscale/server:build:     at writeOrBuffer (node:internal/streams/writable:570:12)
@counterscale/server:build:     at _write (node:internal/streams/writable:499:10)
@counterscale/server:build:     at Socket.Writable.write (node:internal/streams/writable:508:10)
@counterscale/server:build:     at Runtime.updateConfig (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/runtime/index.ts:154:24)
@counterscale/server:build:     at Miniflare2.#assembleAndUpdateConfig (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/index.ts:1398:28)
@counterscale/server:build:     at Mutex.runWith (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/workers/shared/sync.ts:66:45) {
@counterscale/server:build:   errno: -32,
@counterscale/server:build:   code: 'EPIPE',
@counterscale/server:build:   syscall: 'write'
@counterscale/server:build: }
npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path /home/shazow/local/src/github.com/benvinegar/counterscale/packages/server
npm error workspace @counterscale/[email protected]
npm error location /home/shazow/local/src/github.com/benvinegar/counterscale/packages/server
npm error command failed
npm error command sh -c react-router build

@counterscale/server:build: ERROR: command finished with error: command (/home/shazow/local/src/github.com/benvinegar/counterscale/packages/server) /home/shazow/.nix-profile/bin/npm run build exited (1)
@counterscale/server#build: command (/home/shazow/local/src/github.com/benvinegar/counterscale/packages/server) /home/shazow/.nix-profile/bin/npm run build exited (1)

 Tasks:    2 successful, 3 total
Cached:    2 cached, 3 total
  Time:    1.573s
Failed:    @counterscale/server#build

 ERROR  run failed: command  exited (1)
@benvinegar
Copy link
Owner

@shazow 👋

Could you try the following and let me know what you get?

  1. Get the Miniflare version you have installed, it looks different than mine (3.20241218.0):
cat /home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/package.json | grep version
  1. Try running the server build command outside of Turbo (just in case):
npm run build --workspace=@counterscale/server

@shazow
Copy link
Author

shazow commented Feb 4, 2025

$ cat /home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/package.json | grep version
  "version": "3.20241218.0",

$ npm run build --workspace=@counterscale/server

> @counterscale/[email protected] build
> react-router build

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:159:15)
    at writeGeneric (node:internal/stream_base_commons:150:3)
    at Socket._writeGeneric (node:net:964:11)
    at Socket._write (node:net:976:8)
    at writeOrBuffer (node:internal/streams/writable:570:12)
    at _write (node:internal/streams/writable:499:10)
    at Socket.Writable.write (node:internal/streams/writable:508:10)
    at Runtime.updateConfig (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/runtime/index.ts:154:24)
    at Miniflare2.#assembleAndUpdateConfig (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/index.ts:1398:28)
    at Mutex.runWith (/home/shazow/local/src/github.com/benvinegar/counterscale/node_modules/miniflare/src/workers/shared/sync.ts:66:45) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}
npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path /home/shazow/local/src/github.com/benvinegar/counterscale/packages/server
npm error workspace @counterscale/[email protected]
npm error location /home/shazow/local/src/github.com/benvinegar/counterscale/packages/server
npm error command failed
npm error command sh -c react-router build

@benvinegar
Copy link
Owner

benvinegar commented Feb 4, 2025

Looks like it's choking trying to write to stdin:

https://github.com/cloudflare/workers-sdk/blob/main/packages/miniflare/src/runtime/index.ts#L154

		// 3. Write config, and wait for writing to finish
		runtimeProcess.stdin.write(configBuffer);
		runtimeProcess.stdin.end();
		await once(runtimeProcess.stdin, "finish");

I'm feeling like this has something to do with your build environment.

Seems like this person on Stack Overflow may have hit the same issue?

Edit: might be this cloudflare/workers-sdk/issues/3262

@shazow
Copy link
Author

shazow commented Feb 4, 2025

Ah interesting, looks like the nixpkgs version of wrangler does have additional workarounds, I'll see if I can replicate.

@shazow
Copy link
Author

shazow commented Feb 4, 2025

Argh, I'm on a bandwidth-constrained internet for the next week+ so I won't be able to download the full 2gb toolchain to reproduce the environment in the flake, so going to put it off for now. :)

@shazow
Copy link
Author

shazow commented Feb 4, 2025

@benvinegar Btw would it make sense to have a pre-built version of this that can be deployed easily? Or is that ideologically opposing? :)

@benvinegar
Copy link
Owner

@shazow 100% – it's actually already on this branch if you want to give it a try: #153

On that branch, the @counterscale/server package is built and published to npm and pulled down by the CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants