parcel-bundler / parcel

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

After updating to parcel 2.2.1 the build system is flacky. It often fails. It take 2,3,4 runs to make it work. #7590

Closed dailypixie closed 2 years ago

dailypixie commented 2 years ago

šŸ› bug report

After updating to parcel 2.2.1 the build system is flaky. It often fails. It takes 2,3,4 runs to make it work. /c/Program Files/nodejs/npm: line 44: 2128 Segmentation fault "$NODE_EXE" "$NPM_CLI_JS" "$@"

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

parcel watch src/web/pages/**/*.pug --dist-dir ./ --target public
{
  "plugins": [
    [
      "transform-react-pug",
      {
        "classAttribute": "className"
      }
    ],
    "styled-jsx/babel",
    "transform-jsx-css-modules",
    "@babel/plugin-transform-runtime"
  ]
}

šŸ¤” Expected Behavior

It should work the first time.

šŸ˜Æ Current Behavior

After updating to parcel 2.2.1 the build system is flacky. It often fails. It take 2,3,4 runs to make it work. Sometimes it works aftet rimraffing .parcel_cache or npm rebuild, or both.

/c/Program Files/nodejs/npm: line 44: 2128 Segmentation fault "$NODE_EXE" "$NPM_CLI_JS" "$@"

šŸ’ Possible Solution

Sometimes it works aftet rimraffing .parcel_cache or npm rebuild, or both.

šŸ”¦ Context

šŸ’» Code Sample

šŸŒ Your Environment

Software Version(s)
Parcel 2.2.1
Node v16.13.2
npm/Yarn npm 8.1.2
Operating System Windows 10
mischnic commented 2 years ago

Can you share your project or try to reduce it so that you can? There isn't much we can do here without more details

dailypixie commented 2 years ago

The project is private but I can share the package.json "targets": { "public": {}, "www": { "publicUrl": "./", "sourceMap": { "inline": true, "inlineSources": true } }, "dev": { "sourceMap": { "inline": true, "inlineSources": true } }, "prod": { "publicUrl": ".../extension/prod" } }, "scripts": { "watch:website": "npm run clean:website && parcel watch src/web/pages/**/*.pug --dist-dir ./ --target public", }, "devDependencies": { "@babel/core": "7.16.10", "@babel/plugin-transform-runtime": "7.16.10", "@commitlint/cli": "12.1.1", "@commitlint/config-conventional": "12.1.1", "@fontsource/raleway": "4.5.0", "@fortawesome/fontawesome-free": "6.0.0-beta3", "@parcel/config-default": "2.2.1", "@parcel/config-webextension": "2.2.1", "@parcel/packager-raw-url": "2.2.1", "@parcel/reporter-cli": "2.2.1", "@parcel/service-worker": "2.2.1", "@parcel/transformer-pug": "2.2.1", "@parcel/transformer-react-refresh-wrap": "2.2.1", "@parcel/transformer-sass": "2.2.1", "@parcel/transformer-webmanifest": "2.2.1", "@swc/helpers": "0.3.2", "@tensorflow-models/pose-detection": "0.0.6", "@tensorflow/tfjs-backend-cpu": "3.8.0", "@tensorflow/tfjs-backend-wasm": "3.8.0", "@tensorflow/tfjs-backend-webgl": "3.8.0", "@tensorflow/tfjs-converter": "3.8.0", "@tensorflow/tfjs-core": "3.8.0", "@zxing/browser": "0.0.9", "@zxing/library": "0.18.6", "animate.css": "4.1.1", "autocannon": "7.5.0", "babel-eslint": "10.1.0", "babel-plugin-transform-jsx-css-modules": "1.0.0", "babel-plugin-transform-react-pug": "7.0.1", "babel-preset-env": "1.7.0", "bootstrap": "5.1.3", "browser-notification": "3.0.0", "clipboard-polyfill": "3.0.3", "commitlint": "13.1.0", "concurrently": "6.2.0", "copy": "0.3.2", "cordova": "11.0.0", "cordova-android": "10.1.1", "cordova-ios": "6.2.0", "cordova-ios-plugin-no-export-compliance": "0.0.6", "cordova-plugin-android-permissions": "1.1.3", "cordova-plugin-androidx": "3.0.0", "cordova-plugin-androidx-adapter": "1.1.3", "cordova-plugin-badge": "0.8.8", "cordova-plugin-camera": "6.0.0", "cordova-plugin-compat": "1.2.0", "cordova-plugin-device": "2.0.3", "cordova-plugin-idfa": "2.0.0", "cordova-plugin-inappbrowser": "5.0.0", "cordova-plugin-local-notification": "0.9.0-beta.2", "cordova-plugin-network-information": "3.0.0", "cordova-plugin-whitelist": "1.3.5", "cordova-plugin-wkwebview-file-xhr": "3.0.0", "cordova-support-android-plugin": "1.0.2", "dayjs": "1.10.6", "eslint": "7.24.0", "eslint-config-eslint": "7.0.0", "eslint-config-google": "0.14.0", "eslint-config-prettier": "8.2.0", "eslint-plugin-jsdoc": "32.3.0", "eslint-plugin-node": "11.1.0", "eslint-plugin-react": "7.23.2", "eslint-plugin-react-hooks": "4.2.0", "font-awesome": "4.7.0", "fuite": "1.1.0", "howler": "2.2.3", "http-server": "0.12.3", "husky": "6.0.0", "iconoir": "1.0.0", "jetifier": "2.0.0", "localtunnel": "2.0.2", "lodash": "4.17.21", "ncp": "2.0.0", "ngrok": "4.2.2", "nodemon": "2.0.15", "opener": "1.5.2", "parcel": "2.2.1", "parcel-plugin-static-files-copy": "2.6.0", "postcss": "8.3.9", "prettier": "2.3.2", "prop-types": "15.7.2", "pug-cli": "1.0.0-alpha6", "qs": "6.10.3", "quagga": "0.12.1", "react": "17.0.2", "react-bootstrap": "2.1.1", "react-charts": "3.0.0-beta.32", "react-circle-progress-bar": "0.1.4", "react-dom": "17.0.2", "react-lottie-player": "1.4.1", "react-router": "5.2.1", "react-router-dom": "5.2.0", "react-toastify": "8.1.0", "react-transition-group": "4.4.2", "recharts": "2.1.0", "regenerator-runtime": "0.13.9", "rimraf": "3.0.2", "sass": "1.43.2", "scandit-sdk": "5.7.1", "sharp": "0.29.3", "stripe": "8.168.0", "styled-components": "5.2.3", "styled-jsx": "4.0.0", "stylelint": "13.13.1", "stylelint-config-standard": "22.0.0", "stylelint-config-twbs-bootstrap": "2.2.4", "sweetalert2": "11.1.9", "sweetalert2-react-content": "4.2.0", "swiper": "7.0.8", "transition-style": "0.1.1", "turbolinks": "5.2.0", "webextension-polyfill": "0.8.0" }, "dependencies": { "axios": "0.21.1", "bcrypt": "5.0.1", "body-parser": "1.19.1", "compression": "1.7.4", "cookie-parser": "1.4.5", "cors": "2.8.5", "croner": "4.0.79", "date-fns": "2.22.1", "dotenv": "10.0.0", "express": "4.17.1", "express-async-errors": "3.1.1", "express-jwt": "6.0.0", "express-rate-limit": "5.3.0", "express-validator": "6.12.1", "helmet": "4.6.0", "http-status": "1.5.0", "joi": "17.4.2", "jsonwebtoken": "8.5.1", "jwt-decode": "3.1.2", "logform": "2.3.0", "mkdirp": "1.0.4", "mongoose": "5.13.6", "morgan": "1.10.0", "nodemailer": "6.6.3", "validator": "13.6.0", "winston": "3.3.3" },

dailypixie commented 2 years ago

I have a pug entrypoint. I build a custom version of bootstrap 5. Let me know if I can provide further assistance.

AmasiaNalbandian commented 2 years ago

Hello! I am also experiencing the same issue. Unfortunately my repository is also private however I will share as much as I can: dvnYc1dXj9

OR Even using the following: rKWoorIWWs

Software Version(s)
Parcel 2.2.1
Node v16.13.2
npm/Yarn npm 6.* OR 8.3.2 (I upgraded thinking this was it)
Operating System Windows 10

my package.json might be smaller:

{
  "engines": {
    "node": ">=16"
  },
  "source": "src/index.html",
  "browserslist": "> 0.5%, last 2 versions, not dead",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel",
    "build": "parcel build"
  },
  "author": "Amasia",
  "license": "UNLICENSED",
  "devDependencies": {
    "parcel": "^2.2.1"
  },
  "dependencies": {
    "aws-amplify": "^4.0.0"
  }
}
provegard commented 2 years ago

Has anyone managed to downgrade? Since Parcel packages specify dependences using ^ (e.g. https://github.com/parcel-bundler/parcel/blob/v2.2.0/packages/configs/default/package.json#L21), I get 2.2.1 versions even if I specify 2.2.0 in my package.json.

dailypixie commented 2 years ago

yes, i did. I took me about 20 minutes to find all the packages that parcel uses and set a fixed version

    "@parcel/babel-ast-utils": "2.1.1",
    "@parcel/babylon-walk": "2.1.1",
    "@parcel/bundler-default": "2.1.1",
    "@parcel/cache": "2.1.1",
    "@parcel/codeframe": "2.1.1",
    "@parcel/compressor-raw": "2.1.1",
    "@parcel/core": "2.1.1",
    "@parcel/diagnostic": "2.1.1",
    "@parcel/events": "2.1.1",
    "@parcel/fs": "2.1.1",
    "@parcel/fs-search": "2.1.1",
    "@parcel/fs-write-stream-atomic": "2.1.1",
    "@parcel/graph": "2.1.1",
    "@parcel/config-default": "2.1.1",
    "@parcel/logger": "2.1.1",
    "@parcel/markdown-ansi": "2.1.1",
    "@parcel/namer-default": "2.1.1",
    "@parcel/node-libs-browser": "2.1.1",
    "@parcel/node-resolver-core": "2.1.1",
    "@parcel/optimizer-cssnano": "2.1.1",
    "@parcel/optimizer-htmlnano": "2.1.1",
    "@parcel/optimizer-image": "2.1.1",
    "@parcel/optimizer-svgo": "2.1.1",
    "@parcel/optimizer-terser": "2.1.1",
    "@parcel/package-manager": "2.1.1",
    "@parcel/packager-css": "2.1.1",
    "@parcel/packager-html": "2.1.1",
    "@parcel/packager-js": "2.1.1",
    "@parcel/packager-raw": "2.1.1",
    "@parcel/packager-svg": "2.1.1",
    "@parcel/plugin": "2.1.1",
    "@parcel/reporter-dev-server": "2.1.1",
    "@parcel/resolver-default": "2.1.1",
    "@parcel/runtime-browser-hmr": "2.1.1",
    "@parcel/runtime-js": "2.1.1",
    "@parcel/runtime-react-refresh": "2.1.1",
    "@parcel/runtime-service-worker": "2.1.1",
    "@parcel/source-map": "2.0.1",
    "@parcel/transformer-babel": "2.1.1",
    "@parcel/transformer-css": "2.1.1",
    "@parcel/transformer-html": "2.1.1",
    "@parcel/transformer-image": "2.1.1",
    "@parcel/transformer-js": "2.1.1",
    "@parcel/transformer-json": "2.1.1",
    "@parcel/transformer-postcss": "2.1.1",
    "@parcel/transformer-posthtml": "2.1.1",
    "@parcel/transformer-raw": "2.1.1",
    "@parcel/transformer-svg": "2.1.1",
    "@parcel/transformer-webextension": "2.1.1",
    "@parcel/types": "2.1.1",
    "@parcel/utils": "2.1.1",
    "@parcel/watcher": "2.0.5",
    "@parcel/workers": "2.1.1",
    "@parcel/hash": "2.1.1",
    "@parcel/config-webextension": "2.1.1",
    "@parcel/packager-raw-url": "2.1.1",
    "@parcel/reporter-cli": "2.1.1",
    "@parcel/service-worker": "2.1.1",
    "@parcel/transformer-pug": "2.1.1",
    "@parcel/transformer-react-refresh-wrap": "2.1.1",
    "@parcel/transformer-sass": "2.1.1",
    "@parcel/transformer-webmanifest": "2.1.1",
dailypixie commented 2 years ago

Still kinda flaky, but it works in a couple of runs if I


rimraf .parcel_cache
npm rebuild
provegard commented 2 years ago

@dailypixie I ended up doing the same. For reference in case someone needs it:

for dir in $(ls node_modules/\@parcel/); do ver=$(jq '.version' node_modules/\@parcel/$dir/package.json); if [[ "$ver" = "\"2.2.1\"" ]]; then echo "\"@parcel/${dir%/}\": \"2.1.1\","; fi; done

(Works on Cygwin, YMMV.)

But it still crashes a lot for me.

dailypixie commented 2 years ago

Yep, somehow still crashes a lot but it's manageable. It did not crash at all before 2.2.1 update

mischnic commented 2 years ago

What version of lmdb is installed in your project? If you have 2.1.6 installed, try rolling back to 2.1.5 (e.g. via yarn resolutions)

yogensia commented 2 years ago

I have the same issue on an empty test project, there's only a test index.html. Windows 10, Node 16.13.0, npm 8.1.0, Parcel 2.2.1. It worked a couple of times at first, since then it crashes with the segmentation error every time. Clearing cache and rebuilding dependencies doesn't help either in my case. Another clean install with npm i parcel@2.1.1 --save-dev also crashes consistently.

dailypixie commented 2 years ago

@mischnic I rolled back to lmdb 2.1.5, it behaves the same

humphd commented 2 years ago

I have 4 students hitting this bug tonight.

devongovett commented 2 years ago

This is a bit of a mystery to us. 2.2.1 was released almost a week ago, but people only seem to be hitting the issue in the last 2 days or so. Maybe some dependency is causing it? šŸ¤”

humphd commented 2 years ago

FWIW, the people I've seen hit it were all on Windows. I haven't been able to reproduce this on macOS with 2.2.1.

tbekolay commented 2 years ago

I don't think it's Windows specific because I'm on Debian and I am having what I think is a variant of this issue; for me, everything works fine until I press Ctrl+C, at which point I get a Seg fault 100% of the time. When I run a build and it exits on its own I sometimes get the seg fault and sometimes get a double free error. In both cases, everything seems to work fine until the program is exiting.

$ npm start

> start
> parcel

Server running at http://localhost:1234
āœØ Built in 3.17s
Segmentation fault
$ npm run build

> build
> parcel build

āœØ Built in 11.06s

dist/index.html               231 B    286ms
dist/index.f212e599.js    781.97 KB    8.40s
double free or corruption (out)
Aborted

I installed things this morning and it's my first time using parcel so I suspect it's easily reproducible if you start a fresh environment.

devongovett commented 2 years ago

I still haven't been able to recreate it either on macOS or Windows. I've tried both node 14 and 16 with a simple project like one linked here. Anyone have a reproduction in a Docker container or some other way to share it?

dailypixie commented 2 years ago

It started behaving this way after I rimraffed node_modules and cleared npm cache. Is there a way to test this? This is why I prefer fixed dependencies it's like trying to find the needle in the haystack. Do you know what was updated last couple of weeks that might cause this?

frozar commented 2 years ago

This bug seems to be there since a moment now. I ran some test with previous versions of parcel, and even on version 2.0.0, I already see this behavior.

$ npm i -D parcel@2.0.0
$ rm -rf .parcel-cache/ dist/ ; npm run build 

> parcel@1.0.0 build
> parcel build index.html --dist-dir ./dist

āœØ Built in 1.01s

dist/index.html           326 B    392ms
dist/index.98aed748.js     99 B    296ms
free(): invalid pointer
Aborted (core dumped)

My package.json:

$ cat package.json 
{
  "name": "parcel",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "dev": "parcel index.html",
    "build": "parcel build index.html --dist-dir ./dist"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "parcel": "^2.0.0"
  }
}

You can see the tiny example I used to test parcel at: https://github.com/frozar/model/tree/master/parcel

dailypixie commented 2 years ago

Im not sure you are running 2.0.0. Can you check in the node_modules folder, in the package.json file found in parcel folder?

humphd commented 2 years ago

Another thing that may or may not be related: I have other students who are hitting what looks to be the same bug, but it doesn't necessarily crash the same way (i.e., fails but no seg fault). The process seems to get stuck, and holds port 1234 open, blocking future invocations.

contactjavas commented 2 years ago

Having this bug since yesterday. Removing "@parcel/transformer-sass" from my package.json seems fixing it.

alexmarmon commented 2 years ago

Removing @parcel/transformer-sass and rebuilding our lock file didn't seem to fix the issue for us. We're seeing error Command failed with exit code 3221225477 when building with parcel on azure. Bundling locally on macos has no issue. Reverting to 2.0.1 fixed it for now.

devongovett commented 2 years ago

Does it work for anyone if you set the PARCEL_WORKER_BACKEND=process environment variable?

tbekolay commented 2 years ago

Does it work for anyone if you set the PARCEL_WORKER_BACKEND=process environment variable?

Yes, if I set this variable I no longer get seg faults or double frees in Debian! It seems a bit slow to respond to the Ctrl+C signal, but hopefully hearing that it fixes it for me helps track down the issue.

cheeplusplus commented 2 years ago

Does it work for anyone if you set the PARCEL_WORKER_BACKEND=process environment variable?

Can confirm this seems to fix the issue on Windows 10.

frozar commented 2 years ago

On the small example I provided earlier, setting the PARCEL_WORKER_BACKEND environment variable fixes my issue too. The next command executes without crashing at the end under Ubuntu 18.04:

PARCEL_WORKER_BACKEND=process parcel build index.html --dist-dir ./dist
dailypixie commented 2 years ago

Does it work for anyone if you set the PARCEL_WORKER_BACKEND=process environment variable?

Yes, it works on my Windows 10 machine from git bash

josephshen commented 2 years ago

Yes, I also drop the parcel version from 2.2.1 to 2.0.0, these bug still happened on my Windows develop machine.

devongovett commented 2 years ago

I think we narrowed this down to an upgrade of napi-rs in the @parcel/source-map package, which was released sometime after Parcel 2.2.1. I still don't know the exact root cause, but for now I've reverted this upgrade and published @parcel/source-map v2.0.2. See https://github.com/parcel-bundler/source-map/pull/91.

You'll need to remove @parcel/source-map 2.0.1 from your lock file and re-install to get the upgrade. Please comment whether this works for you. Apologies again for the issue, and thanks for your patience while we track it down.

yogensia commented 2 years ago

Please comment whether this works for you.

Seems to work for me after reinstalling (and reverting the PARCEL_WORKER_BACKEND=process envar fix, using Win10 & git bash). Tested a couple of projects and restarted parcel several times and I can't reproduce the "segmentation fault" errors anymore.

nunof07 commented 2 years ago

You'll need to remove @parcel/source-map 2.0.1 from your lock file and re-install to get the upgrade. Please comment whether this works for you. Apologies again for the issue, and thanks for your patience while we track it down.

Can confirm this works for me as well. Thank you!