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

Chunk's auxiliaryFiles set contains undefined #18102

Open
svallory opened this issue Feb 20, 2024 · 4 comments
Open

Chunk's auxiliaryFiles set contains undefined #18102

svallory opened this issue Feb 20, 2024 · 4 comments

Comments

@svallory
Copy link

Bug report

I'm so sorry I can't provide a simple reproduction. I'm using Sharetribe Web Template (which is based on create-react-app) but injecting an Astro rendered site inside it. Also, they Sharetribe customized react-scripts which I also had to modify to add an html-loader. So, as you imagine` the whole setup is a mess.

But I'm really in a hurry to deliver this project so any help or tip on how to hunt this issue down myself is really appreciated.

Also, if this turns out to be a bug in webpack, I don't mind making a PR to fix it.

The react-scripts can be found here: https://github.com/tokilabs/calligo-sharetribe-scripts/tree/master/packages/react-scripts

Some files of interest:

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

This issue only happens during build, during dev (handled by start.js script) everything works fine

The issue is that a Chunk contains is emitted which contains an undefined value in the auxiliaryFiles array. Which causes the webpack-manifest-plugin to throw the famous The "path" argument must be of type string. Received undefined error.

I updated both webpack and webpack-manifest-plugin to the latest version and the error persists.

Chunk {
  id: 1590,
  ids: [ 1590 ],
  debugId: 1223,
  name: 'main',
  idNameHints: SortableSet(0) [Set] {
    _sortFn: undefined,
    _lastActiveSortFn: Symbol(not sorted),
    _cache: undefined,
    _cacheOrderIndependent: undefined
  },
  preventIntegration: false,
  filenameTemplate: undefined,
  cssFilenameTemplate: undefined,
  _groups: SortableSet(1) [Set] {
    Entrypoint {
      groupDebugId: 5223,
      options: [Object],
      _children: [SortableSet [Set]],
      _parents: [SortableSet [Set]],
      _asyncEntrypoints: [SortableSet [Set]],
      _blocks: [SortableSet [Set]],
      chunks: [Array],
      origins: [Array],
      _modulePreOrderIndices: [Map],
      _modulePostOrderIndices: [Map],
      index: 0,
      _runtimeChunk: [Circular *1],
      _entrypointChunk: [Circular *1],
      _initial: true
    },
    _sortFn: [Function: compareChunkGroupsByIndex],
    _lastActiveSortFn: Symbol(not sorted),
    _cache: undefined,
    _cacheOrderIndependent: undefined
  },
  runtime: 'main',
  files: SetDeprecatedArray(2) [Set] {
    'static/css/main.197612e5.css',
    'static/js/main.4d49beed.js'
  },
  auxiliaryFiles: Set(29) {
    undefined,
    'static/media/ajuda.6YqU9CzO_12KKKI.1040acbd8ce60d962529.webp',
    'static/media/aspas-1.z59pUXt-_1eRcin.2f2e124ec067761e5e85.webp',
    'static/media/aspas-2.-EiBRoJU_ZHdEGP.7f94225a67e9f54574e7.webp',
    'static/media/brandname-mobile.cE0fo98j_yPyW6.5aa727667d024e408330.webp',
    'static/media/brandname.R6hE-dgi_Z24WGa9.8b6a8cb15d446ba324ed.webp',
    'static/media/close-button.xvo2w6Qb_ZCNIrY.3f64e46271ec3784df49.webp',
    'static/media/home-banner-1.fvKG1TnX_Z1W5NLe.1927c91520b372fd25a3.webp',
    'static/media/home-banner-2.WYXhwgI5_Z1S0yVs.578270f245ad21a975b9.webp',
    'static/media/icon_24h.b2JuyspM_Z1i2vwG.917c619d4fe0b5cf6f57.webp',
    'static/media/icon_mic.AR32n9vK_Z1RNmzF.6df7a7f5e8e45a0a5f62.webp',
    'static/media/icon_quality.HUQTyq3i_Z1HViM0.b94727adc5460117c00c.webp',
    'static/media/icon_security.qVqq06UK_Z22QDpX.1d7be0c0afc854e1e690.webp',
    'static/media/ilustra_whyTherapy.SzFvI7Cm_Z1kSpyu.5e18e3a4648111e78b25.webp',
    'static/media/ilustracao-1.IA7dMa1K_Z1FLGuf.0c16543c21e8481a3b53.webp',
    'static/media/ilustracao-2.piZ1cl7N_ZPl9VA.2a5e03e4ed70f95934f7.webp',
    'static/media/intro-image-mobile.YjE86yTX_Z2s0Nzg.474ff6231b0f3d1eae95.webp',
    'static/media/logo-mobile-white.EROkUeKD_ZOhhKN.3d4327dfad3049f40381.webp',
    'static/media/logo-mobile.5O6x2LMT_2tfGEI.1940a1107bc7f1a0a1f9.webp',
    'static/media/menu-icon-white.SkmDkwAX_Z20v2Md.f1779de8e6c3fe1089b5.webp',
    'static/media/menu-icon.Vo66JKZW_ZvRFz2.362b30f7c2ea270b2466.webp',
    'static/media/play.l9OIX63r_Zn8ImP.4029d2e2490cb1a824d9.webp',
    'static/media/biketribe-brandImage-1500.ec1b40e5a91c583c7295.jpg',
    'static/media/biketribe-facebook-sharing-1200x630.e244f01f60dd7ddc16c1.jpg',
    'static/media/biketribe-logo-desktop.c130ff2b233ec5e2ef55.png',
    'static/media/biketribe-twitter-sharing-600x314.d1d46bae577cac2c840a.jpg',
    'static/media/hoisted.Qrnbjwdl.af6c33e948be84d6612c.js',
    'static/css/main.197612e5.css.map',
    'static/js/main.4d49beed.js.map'
  },
  rendered: true,
  hash: 'c6ab5d7bc99144ce0702bc19e69e22b7',
  contentHash: [Object: null prototype] {
    'css/mini-extract': '1adc89212a36c9c70659',
    javascript: 'dc0fcfb331e40e903b16'
  },
  renderedHash: 'c6ab5d7bc99144ce0702',
  chunkReason: undefined,
  extraAsync: false
}

Stack Trace

HookWebpackError: The "path" argument must be of type string. Received undefined
    at makeWebpackError (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack/lib/HookWebpackError.js:48:9)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack/lib/Compilation.js:3075:12
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
    at fn (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack/lib/Compilation.js:481:17)
    at _next7 (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
-- inner error --
TypeError: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Object.basename (node:path:1308:5)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/helpers.js:66:26
    at Array.forEach (<anonymous>)
    at Object.reduceChunk (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/helpers.js:60:44)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/hooks.js:43:82
    at Array.reduce (<anonymous>)
    at WebpackManifestPlugin.emit (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/hooks.js:43:48)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/index.js:66:72
    at fn (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack/lib/Compilation.js:479:10)
    at _next7 (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
caused by plugins in Compilation.hooks.processAssets
TypeError: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Object.basename (node:path:1308:5)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/helpers.js:66:26
    at Array.forEach (<anonymous>)
    at Object.reduceChunk (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/helpers.js:60:44)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/hooks.js:43:82
    at Array.reduce (<anonymous>)
    at WebpackManifestPlugin.emit (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/hooks.js:43:48)
    at /Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack-manifest-plugin/dist/index.js:66:72
    at fn (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/webpack/lib/Compilation.js:479:10)
    at _next7 (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)
    at eval (eval at create (/Users/svallory/projects/calligo/workspace/repos/scripts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

What is the expected behavior?

I believe webpack shouldn't have an undefined in the set of chunk.auxiliaryFiles

Other relevant information:
webpack version: 5.90.3
Node.js version: 18.18.2
Operating System: OS X
Additional tools:

@alexander-akait
Copy link
Member

Sounds like a bug in non official webpack plugin, we need reproducible test repo to fix a place

@svallory
Copy link
Author

Sounds like a bug in non official webpack plugin, we need reproducible test repo to fix a place

As I said, I don't mind hunting it down. The error blows up in webpack-manifest-loader but the real issue is that the main chunk is generated with an undefined value in the axuiliaryFiles.

I checked the documentation but did not find a good explanation of how chunks are created in webpack.

With some guidance, mainly regarding how chunks are created in webpack and what's the role of loaders in it, I could isolate the real culprit and create a reproduction.

@alexander-akait
Copy link
Member

alexander-akait commented Feb 22, 2024

You can use proxy (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) on the auxiliaryFiles field (just do patch inside webpack in your dev deps) and find where it was added

@svallory
Copy link
Author

You can use proxy (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) on the auxiliaryFiles field (just do patch inside webpack in your dev deps) and found where it was added

excelent idea! (why didn't I thought of that?! 🤦🏻)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority - Medium
Development

No branches or pull requests

2 participants