parcel-bundler / parcel

The zero configuration build tool for the web. πŸ“¦πŸš€
https://parceljs.org
MIT License
43.52k stars 2.26k forks source link

`build watch` hangs under supervision #9991

Open nyarly opened 1 month ago

nyarly commented 1 month ago

πŸ› bug report

I run my dev environment under process-compose. When I try to add parcel watch to my process-compose.yaml, it runs but never gets past $ .../frontend/src/node_modules/.bin/parcel watch --dist-dir ../dist/

In fact, yarn parcel stops responding to SIGINT, which means that process-compose won't exit cleanly either. I have to pkill -9 yarn.

πŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "name": "wagthepig-frontend",
  "source": "html/index.html",
  "distDir": "../dist",
  "devDependencies": {
    "@parcel/transformer-elm": "2.12.0",
    "elm": "^0.19.1-5",
    "parcel": "^2.12.0"
  }
}

πŸ€” Expected Behavior

parcel watch would run as part of my dev environment.

😯 Current Behavior

It hangs early, doesn't build, and stops my environment process supervisor from working.

πŸ’ Possible Solution

I do not have the expertise with Node to debug this level of OS issue.

πŸ”¦ Context

I'm trying to use parcel as part of a full stack app, and incorporate it into a build environment that works for that.

πŸ’» Code Sample

?

🌍 Your Environment

Software Version(s)
Parcel 2.12
Node 22.9
npm/Yarn 1.22
Operating System NixOS 24.05
LeoniePhiline commented 4 weeks ago

I experience the same issue, where parcel watch freezes and is not even stoppable with Ctrl + C.

I commonly run docker compose exec "$@" www-node pnpm run --color watch, which invokes parcel watch as configured in package.json as "scripts": { "watch": "parcel watch" }.

It does run for a while, until it doesn't. I could not observe any reason for failure.

When it stops running, it just gets stuck on the last "✨ Built in [...]ms" and stops reacting to changed files or keyboard interrupts.

Note that I run pnpm rather than yarn, which makes this seem like a parcel issue, not a yarn issue.

Also note that this is not an issue of forwarding keyboard interrupts into the container: Before parcel watch freezes up, it is stoppable with Ctrl + C.

Using pnpm 9.10.0 and parcel 2.12.0 on node 22.6.0.

I will try capturing anything useful with parcel watch --trace.

Edit:

Nothing of interest was found in the resulting JSON trace files.

All in all, 6 trace files were generated within a span of 16 minutes and 21 seconds.

❯ eza -lg parcel-trace-*
Permissions Size User   Group Date Modified Git Name
.rw-r--r--  1,0k username users 29 Oct 19:28   -N parcel-trace-20241029-182826.json
.rw-r--r--  3,9k username users 29 Oct 19:37   -N parcel-trace-20241029-183738.json
.rw-r--r--  2,2k username users 29 Oct 19:40   -N parcel-trace-20241029-184002.json
.rw-r--r--  3,4k username users 29 Oct 19:40   -N parcel-trace-20241029-184022.json
.rw-r--r--  2,2k username users 29 Oct 19:40   -N parcel-trace-20241029-184041.json
.rw-r--r--  2,2k username users 29 Oct 19:44   -N parcel-trace-20241029-184447.json

Then, parcel watch hung, not generating any new tracing, not rebuilding, and not reacting to keyboard interrupt.

❯ ps aux | rg -F parcel
username     88968  0.1  0.8 3319120 282692 pts/1  Sl+  19:28   0:04 node /app/packages/some_package/node_modules/.bin/../parcel/lib/bin.js watch --trace

❯ kill -9 88968

The process was not killable by kill / kill -15 (SIGTERM) and required kill -9 (SIGKILL) to be force-terminated.

Trying to restart parcel watch was not possible (without deleting .parcel-cache/:

❯ docker compose exec "$@" www-node pnpm run --color watch        

> some-package@0.1.0 watch /app/packages/some_package
> parcel watch

Error: Does not have node 27079
    at RequestGraph._assertHasNodeId (/app/packages/some_package/node_modules/.pnpm/@parcel+graph@3.2.0/node_modules/@parcel/graph/lib/Graph.js:449:13)
    at RequestGraph.getNodeIdsConnectedTo (/app/packages/some_package/node_modules/.pnpm/@parcel+graph@3.2.0/node_modules/@parcel/graph/lib/Graph.js:77:10)
    at RequestGraph.respondToFSEvents (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/RequestTracker.js:459:26)
    at loadRequestGraph (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/RequestTracker.js:873:18)
    at async RequestTracker.init (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/RequestTracker.js:822:17)
    at async Parcel._init (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/Parcel.js:188:28)
    at async Parcel.watch (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/Parcel.js:260:7)
    at async run (/app/packages/some_package/node_modules/.pnpm/parcel@2.12.0_@swc+helpers@0.5.13_postcss@8.4.47/node_modules/parcel/lib/cli.js:283:9)
 ELIFECYCLE  Command failed with exit code 1.

Furthermore, successfully running parcel build --no-optimize was not possible (without deleting .parcel-cache/:

❯ docker compose exec "$@" www-node pnpm run --color dev   

> some-package@0.1.0 dev /app/packages/some_package
> parcel build --no-autoinstall --no-optimize

(node:938) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
🚨 Build failed.

Error: Expected content key a4097ade3bf2079c to exist

  Error: Expected content key a4097ade3bf2079c to exist
      at nullthrows (/app/packages/some_package/node_modules/.pnpm/nullthrows@1.1.1/node_modules/nullthrows/nullthrows.js:7:15)
      at AssetGraph.getNodeIdByContentKey (/app/packages/some_package/node_modules/.pnpm/@parcel+graph@3.2.0/node_modules/@parcel/graph/lib/ContentGraph.js:67:38)
      at /app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/SymbolPropagation.js:52:82
      at Array.map (<anonymous>)
      at propagateSymbols (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/SymbolPropagation.js:52:61)
      at AssetGraphBuilder.build (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/requests/AssetGraphRequest.js:174:62)
      at async Object.run (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/requests/AssetGraphRequest.js:62:37)
      at async RequestTracker.runRequest (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/RequestTracker.js:673:20)
      at async Object.run (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:106:11)
      at async RequestTracker.runRequest (/app/packages/some_package/node_modules/.pnpm/@parcel+core@2.12.0_@swc+helpers@0.5.13/node_modules/@parcel/core/lib/RequestTracker.js:673:20)

 ELIFECYCLE  Command failed with exit code 1.

Parcel cache was corrupted. To make building succeed again, rm -r packages/some_package/.parcel-cache was required.

ggallo909 commented 1 week ago

I have the same exact issue. As context I'd add that I'm working with windows + wsl with a ubuntu distro and docker (DDEV). Even disabling the cache with the --no-cache flag didn't help.

I experience the same issue, where parcel watch freezes and is not even stoppable with Ctrl + C.

I commonly run docker compose exec "$@" www-node pnpm run --color watch, which invokes parcel watch as configured in package.json as "scripts": { "watch": "parcel watch" }.

It does run for a while, until it doesn't. I could not observe any reason for failure.

When it stops running, it just gets stuck on the last "✨ Built in [...]ms" and stops reacting to changed files or keyboard interrupts.