parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.37k stars 2.26k forks source link

`Error: Expected content key 0788422aa91f880f to exist` when renaming `.tsx` -> `.ts` #6528

Open danieltroger opened 3 years ago

danieltroger commented 3 years ago

🐛 bug report

parcel serve crashes when renaming a file from .ts to .tsx to .ts

✨ Built in 154ms
Error: Expected content key 0788422aa91f880f to exist
    at nullthrows (/private/tmp/parcel-weird-transformations/node_modules/nullthrows/nullthrows.js:7:15)
    at ContentGraph.getNodeIdByContentKey (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/ContentGraph.js:90:38)
    at BundleGraph.getDependencies (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/BundleGraph.js:588:30)
    at BundleGraph.getDependencies (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/public/BundleGraph.js:198:48)
    at /private/tmp/parcel-weird-transformations/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:108:46
    at /private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:55:30
    at PromiseQueue._runFn (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:108:13)
    at PromiseQueue._next (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:95:16)
    at PromiseQueue.run (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:86:12)
    at HMRServer.emitUpdate (/private/tmp/parcel-weird-transformations/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:135:30) {
  framesToPop: 1
}
Error: Expected content key 0788422aa91f880f to exist
    at nullthrows (/private/tmp/parcel-weird-transformations/node_modules/nullthrows/nullthrows.js:7:15)
    at ContentGraph.getNodeIdByContentKey (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/ContentGraph.js:90:38)
    at BundleGraph.getDependencies (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/BundleGraph.js:588:30)
    at BundleGraph.getDependencies (/private/tmp/parcel-weird-transformations/node_modules/@parcel/core/lib/public/BundleGraph.js:198:48)
    at /private/tmp/parcel-weird-transformations/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:108:46
    at /private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:55:30
    at PromiseQueue._runFn (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:108:13)
    at PromiseQueue._next (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:95:16)
    at PromiseQueue.run (/private/tmp/parcel-weird-transformations/node_modules/@parcel/utils/lib/PromiseQueue.js:86:12)
    at HMRServer.emitUpdate (/private/tmp/parcel-weird-transformations/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:135:30) {
  framesToPop: 1
}
error Command failed with exit code 1.

🎛 Configuration (.babelrc, package.json, cli command)

Please see attached .zip

🤔 Expected Behavior

No crash

😯 Current Behavior

Crash

💁 Possible Solution

Fix crash

🔦 Context

Was renaming a file because I wanted to use jsx in it but then I chickened out.

💻 Code Sample

Download this: parcel-rename-crash.zip

  1. Unzip
  2. yarn install
  3. yarn serve
  4. In other terminal window: cd src
  5. mv stuff.ts stuff.tsx
  6. mv stuff.tsx stuff.ts
  7. Switch back to other terminal window and observe that parcel has crashed

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.746+d1e0a1a0
Node v16.4.0
npm/Yarn yarn 1.22.10
Operating System macOS 10.15.7 (19H1217)
Booteille commented 1 year ago

Hi.

I am getting a similar issue since 2.8.3. Downgrading to 2.8.2 makes the build work again.

Here are my dependencies:

  "devDependencies": {
    "@fortawesome/fontawesome-svg-core": "6.2.1",
    "@fortawesome/free-regular-svg-icons": "6.2.1",
    "@fortawesome/free-solid-svg-icons": "6.2.1",
    "@fortawesome/vue-fontawesome": "3.0.0-5",
    "@parcel/config-webextension": "2.8.2",
    "@parcel/core": "2.8.2",
    "@parcel/optimizer-data-url": "2.8.2",
    "@parcel/transformer-inline-string": "2.8.2",
    "@parcel/transformer-typescript-tsc": "2.8.2",
    "@parcel/transformer-vue": "2.8.2",
    "@peertube/peertube-types": "5.0.1",
    "@types/download": "8.0.2",
    "@types/lodash.defaults": "4.2.7",
    "@types/lodash.get": "4.4.7",
    "@types/lodash.set": "^4.3.7",
    "@types/webextension-polyfill": "0.10.0",
    "@typescript-eslint/eslint-plugin": "5.48.2",
    "@typescript-eslint/parser": "5.48.2",
    "@vue/eslint-config-prettier": "^7.0.0",
    "@vue/eslint-config-typescript": "11.0.2",
    "bestzip": "2.2.1",
    "eslint": "8.32.0",
    "eslint-config-standard-with-typescript": "31.0.0",
    "eslint-plugin-import": "2.27.5",
    "eslint-plugin-n": "^15.6.1",
    "eslint-plugin-node": "11.1.0",
    "eslint-plugin-promise": "6.1.1",
    "eslint-plugin-vue": "9.9.0",
    "lodash.defaults": "4.2.0",
    "lodash.get": "4.4.2",
    "lodash.set": "4.3.2",
    "parcel": "2.8.2",
    "prettier": "2.8.3",
    "prettier-eslint": "15.0.1",
    "rimraf": "4.1.1",
    "ts-results": "^3.3.0",
    "typescript": "4.9.4",
    "vue": "3.2.45",
    "vue-eslint-parser": "9.1.0",
    "vue-tsc": "1.0.24",
    "vue3-popper": "1.5.0",
    "webextension-polyfill": "0.10.0"
  }

and the command used to build:

"watch": "parcel manifest.json --config @parcel/config-webextension --target webext-dev"

The stack trace:

Server running at http://localhost:1234
🚨 Build failed.

@parcel/bundler-default: Expected content key ce02aa4519cef13e to exist

  Error: Expected content key ce02aa4519cef13e to exist
      at nullthrows (/home/booteille/Dev/peertube-companion/node_modules/nullthrows/nullthrows.js:7:15)
      at ContentGraph.getNodeIdByContentKey
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/graph/lib/ContentGraph.js:81:38)
      at getReachableBundleRoots
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:1161:44)
      at createIdealGraph
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:728:21)
      at Object.bundle
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:122:19)
      at BundlerRunner.bundle
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:288:23)
      at async Object.run
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:156:17)
      at async RequestTracker.runRequest
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Object.run
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:56:7)
      at async RequestTracker.runRequest
  (/home/booteille/Dev/peertube-companion/node_modules/@parcel/core/lib/RequestTracker.js:756:20)

Yarn version 1.22.19 on Linux Pop!_OS 22.04 LTS

mellodev commented 1 year ago

Having the same issue after upgrading to 2.8.3 from 2.8.2. Large project that's a mix of javascript and typescript, builds fine on 2.8.2. We do have some typescript, but there was no renaming involved as in OP 's case. The only change for us were the 2.8.2 to 2.8.3 dependency updates:

@parcel/bundler-default: Expected content key ed1e7723260a20a6 to exist

  Error: Expected content key ed1e7723260a20a6 to exist
      at nullthrows (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/nullthrows@1.1.1/node_modules/nullthrows/nullthrows.js:7:15)
      at ContentGraph.getNodeIdByContentKey (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+graph@2.8.3/node_modules/@parcel/graph/lib/ContentGraph.js:81:38)
      at getReachableBundleRoots (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+bundler-default@2.8.3_@parcel+core@2.8.3/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:1161:44)
      at createIdealGraph (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+bundler-default@2.8.3_@parcel+core@2.8.3/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:728:21)
      at Object.bundle (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+bundler-default@2.8.3_@parcel+core@2.8.3/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:122:19)
      at BundlerRunner.bundle (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+core@2.8.3/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:288:23)
      at async Object.run (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+core@2.8.3/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:156:17)
      at async RequestTracker.runRequest (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+core@2.8.3/node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Object.run (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+core@2.8.3/node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:56:7)
      at async RequestTracker.runRequest (/home/joel/development/Brainiac-UI/apps/cms/node_modules/.pnpm/@parcel+core@2.8.3/node_modules/@parcel/core/lib/RequestTracker.js:756:20)

Dev dependencies:

"devDependencies": {
    "@babel/core": "7.16.7",
    "@babel/plugin-proposal-class-properties": "7.13.0",
    "@babel/plugin-proposal-object-rest-spread": "7.8.3",
    "@babel/plugin-transform-object-assign": "7.8.3",
    "@babel/preset-env": "7.16.8",
    "@babel/preset-react": "7.16.7",
    "@babel/preset-typescript": "7.13.0",
    "@parcel/babel-preset-env": "2.8.3",
    "@parcel/core": "2.8.3",
    "@parcel/transformer-less": "2.8.3",
    "@types/bluebird": "3.5.36",
    "@types/enzyme": "3.10.8",
    "@types/flux": "3.1.9",
    "@types/jest": "25.1.5",
    "@types/jquery": "3.5.1",
    "@types/prop-types": "15.7.3",
    "@types/react": "15.6.20",
    "@types/react-bootstrap": "0.32.25",
    "@types/react-intl": "2.3.18",
    "@types/react-router": "2.0.57",
    "@types/react-select": "2.0.19",
    "@types/superagent": "3.8.3",
    "@types/uuid": "8.3.4",
    "@typescript-eslint/eslint-plugin": "4.29.3",
    "@typescript-eslint/parser": "4.29.3",
    "babel-eslint": "10.1.0",
    "babel-jest": "25.1.0",
    "babel-loader": "8.0.6",
    "babel-plugin-istanbul": "6.0.0",
    "core-js": "3.20.2",
    "css-loader": "6.5.1",
    "css-minimizer-webpack-plugin": "3.3.1",
    "deep-diff": "1.0.2",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-15": "1.4.3",
    "enzyme-to-json": "3.6.1",
    "eslint": "7.32.0",
    "eslint-webpack-plugin": "3.2.0",
    "html-loader": "3.1.0",
    "html-webpack-plugin": "5.5.0",
    "jest": "29.3.1",
    "jest-environment-jsdom": "29.3.1",
    "jest-environment-node": "29.3.1",
    "jest-junit": "10.0.0",
    "less": "3.12.2",
    "less-loader": "10.2.0",
    "mini-css-extract-plugin": "2.4.6",
    "mockdate": "2.0.5",
    "parcel": "2.8.3",
    "parcel-reporter-static-files-copy": "1.4.0",
    "process": "0.11.10",
    "punycode": "1.4.1",
    "react-test-renderer": "15.6.2",
    "regenerator-runtime": "0.13.3",
    "string_decoder": "1.3.0",
    "style-loader": "3.3.1",
    "terser-webpack-plugin": "5.3.0",
    "ts-loader": "9.2.6",
    "typescript": "4.2.4",
    "webpack": "5.66.0"
  },

Versions

[mellodev/feat/BRAIN-4046-parcel] joel@calcite:~/development/Brainiac-UI/apps/cms$ pnpm --version
7.25.1
[mellodev/feat/BRAIN-4046-parcel] joel@calcite:~/development/Brainiac-UI/apps/cms$ uname -a
Linux calcite 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 GNU/Linux
[mellodev/feat/BRAIN-4046-parcel] joel@calcite:~/development/Brainiac-UI/apps/cms$ node --version
v16.15.1
danieltroger commented 1 year ago

Also getting this randomly now without renaming files, since starting to use yarn workspaces. Example error:

🚨 Build failed.

Error: Key 29790583eac75c05 not found in cache

  Error: Key 29790583eac75c05 not found in cache
      at LMDBCache.getBlob 
  (/Users/daniel/Documents/depict.ai/browser-tags-v2/.yarn/__virtual__/@parcel-cache-virtual-f4ec14de82/0/cache/@parcel-cache-npm-2.8.3-7b70a160bc-cd679053d2.zip/node_modules/@parcel/cache/lib/LMDBCache.js:130:70)
      at Object.run (/Users/daniel/Documents/depict.ai/browser-tags-v2/.yarn/cache/@parcel-core-npm-2.8.3-1751106c31-68adceb1b0.zip/node_modules/@parcel/core/lib/requests/WriteBundleRequest.js:165:68)
      at async RequestTracker.runRequest 
  (/Users/daniel/Documents/depict.ai/browser-tags-v2/.yarn/cache/@parcel-core-npm-2.8.3-1751106c31-68adceb1b0.zip/node_modules/@parcel/core/lib/RequestTracker.js:756:20)

Unsure if creating another reproduction would help getting this fixed?

ted-palmer commented 1 year ago

I'm running into a similar issue #8874. Only happens for me when I run parcel watch. parcel build works fine. Here's a link to reproducible example

mellodev commented 1 year ago

Hi @mischnic do you know if anyone is working on this bug?

ttodua commented 5 months ago

This might help https://stackoverflow.com/a/77391012/2377343

Nukesor commented 2 days ago

This might help https://stackoverflow.com/a/77391012/2377343

Nice, that was actually it for me. The .parcel-cache was somehow corrupted. It seems that the parcel cache sometimes needs to be killed when updating. Might be a nice improvement to do that automatically on discovery of a new version in the future?