parcel icon indicating copy to clipboard operation
parcel copied to clipboard

Got unexpected undefined DefaultBundler.js:595

Open yrral86 opened this issue 1 year ago • 2 comments

🐛 bug report

@parcel/bundler-default: Got unexpected undefined

  Error: Got unexpected undefined

      at nullthrows 
  (node_modules/nullthrows/nullthrows.js:7:15)
      at createIdealGraph 
  (node_modules/@parcel/bundler-default/lib/DefaultBundler.js:595:68)
      at Object.bundle 
  (node_modules/@parcel/bundler-default/lib/DefaultBundler.js:118:19)
      at BundlerRunner.bundle 
  (node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:261:23)
      at async Object.run 
  (node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:129:17)
      at async RequestTracker.runRequest 
  (node_modules/@parcel/core/lib/RequestTracker.js:673:20)
      at async Object.run 
  (node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:52:7)
      at async RequestTracker.runRequest 
  (node_modules/@parcel/core/lib/RequestTracker.js:673:20)
      at async Parcel._build 
  (node_modules/@parcel/core/lib/Parcel.js:336:11)
      at async Parcel.run 
  (node_modules/@parcel/core/lib/Parcel.js:205:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I added some debugging logs before the for loop and found that when this executes both bundleRoots and assetToIndex are empty objects, but now I'm confused that it is entering the for loop at all with bundleRoots being empty.

console.log(`debugging: bundleRoots = ${JSON.stringify(bundleRoots)}`)
console.log(`debugging: assetToIndex = ${JSON.stringify(assetToIndex)}`)

If I also log root inside the loop, that also shows as an empty object.

If I continue to rerun the build without clearing the cache, it eventually succeeds. When it does, none of the the debug logs are displaying

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

babel.config.json

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-typescript",
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "babel-plugin-transform-import-meta",
    "babel-plugin-dynamic-import-node"
  ],
  "sourceType": "unambiguous"
}

🤔 Expected Behavior

The application should compile or at least provide a hint as to what went wrong.

😯 Current Behavior

The build crashes.

🔦 Context

We are using the following parcel modules

    "@parcel/packager-raw-url": "2.12.0",
    "@parcel/transformer-sass": "2.12.0",
    "@parcel/transformer-webmanifest": "2.12.0",
    "parcel": "2.12.0",
    "parcel-reporter-static-files-copy": "^1.5.2",
    "parcel-resolver-ignore": "^2.1.5",

This setup works on our main branch, but we're maintaining a branch with significant changes to our typescript code and when we merged in a recent upgrade from 2.7.0 to 2.12.0, this broke.

💻 Code Sample

Code is unfortunately not sharable.

🌍 Your Environment

Software Version(s)
Parcel 2.12.0
Node 20.11.0
npm/Yarn yarn 1.22.19
Operating System OSX M3

yrral86 avatar Aug 15 '24 15:08 yrral86

I walked back versions. My project compiles okay on 2.9.0, but breaks on 2.10 - 2.12. 2.10 and 2.11 have a slightly different stack trace than 2.12:

🚨 Build failed.


@parcel/bundler-default: Got unexpected undefined
  Error: Got unexpected undefined

      at nullthrows 
  (node_modules/nullthrows/nullthrows.js:7:15)
      at createIdealGraph 
  (node_modules/@parcel/bundler-default/lib/DefaultBundler.js:686:68)
      at Object.bundle 
  (node_modules/@parcel/bundler-default/lib/DefaultBundler.js:123:19)
      at BundlerRunner.bundle 
  (node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:260:23)
      at async Object.run 
  (node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:128:17)
      at async RequestTracker.runRequest 
  (node_modules/@parcel/core/lib/RequestTracker.js:637:20)
      at async Object.run 
  (node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:51:7)
      at async RequestTracker.runRequest 
  (node_modules/@parcel/core/lib/RequestTracker.js:637:20)
      at async Parcel._build 
  (node_modules/@parcel/core/lib/Parcel.js:315:11)
      at async Parcel.run 
  (node_modules/@parcel/core/lib/Parcel.js:206:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

yrral86 avatar Aug 15 '24 15:08 yrral86

I also tried using getOwnPropertyNames on bundleRoots and the individual root variables, but both return empty arrays, so it doesn't seem to be an enumerable = false issue 🤷

yrral86 avatar Aug 15 '24 15:08 yrral86

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

github-actions[bot] avatar Feb 12 '25 00:02 github-actions[bot]