rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Bug]: broken caused by `@rspack/lite-tabable` reading a property from `undefined`

Open Helium-Z opened this issue 1 year ago • 1 comments

System Info

System: OS: macOS 14.6.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 81.11 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.4/bin/yarn npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm Browsers: Chrome: 129.0.6668.59 Safari: 17.6

Details

Hi, guys! Thanks for your amazing tool!

I'm migrating my project from Webpack to Rspack now, and met a problem caused by @rspack/lite-tapable reading property from undefined.

I don't find the Repo of that package, so I raise a issue here. The code is as below:

node_modules/@rspack/lite-tapable/dist/index.js L485 image

I don't know if this problem can be fixed via adding a return if tap is undefined. I think it's caused by Webpack plugins I used. If you need any more info, please notify me.

Reproduce link

No response

Reproduce Steps

Sorry, I cannot provide a repo to reproduce this problem for you now. But if this is necessary, I will try.

Helium-Z avatar Sep 25 '24 02:09 Helium-Z

please provide full error report, the reason most lie in plugin use some unsupported hook so we need more error info

hardfist avatar Sep 25 '24 02:09 hardfist

Here is the error details:

[ERROR] unhandledRejection TypeError: Cannot read properties of undefined (reading 'type')
    at next (/Users/helium/workspace/pas/node_modules/@rspack/lite-tapable/dist/index.js:486:21)
    at /Users/helium/workspace/pas/node_modules/@rspack/lite-tapable/dist/index.js:516:29
    at Object.fn (/Users/helium/workspace/pas/node_modules/@xxx/module-federation-typescript/src/plugins/FederatedTypesPlugin.js:70:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

And here is the plugin codes:

Image

Helium-Z avatar Oct 08 '24 09:10 Helium-Z

I think I have a similar issue. As soon as the module federation plugin is added to the plugins array the error is generated.

versions

@module-federation/enhanced: 0.6.8
@rspack/*: 1.0.10

error:

Image

reproduction project: https://github.com/swalker326/ze-workspace

swalker326 avatar Oct 13 '24 15:10 swalker326

I was using the wrong import, I wanted to delete my comment but will keep it here in case anyone else runs into this issue.

import {ModuleFederationPlugin} from @module-federation/enhanced/rspack

swalker326 avatar Oct 13 '24 16:10 swalker326

at Object.fn (/Users/helium/workspace/pas/node_modules/@xxx/module-federation-typescript/src/plugins/FederatedTypesPlugin.js:70:21)

Seems this error is caused by another plugin which touches the internal objects of tapable, perhaps need a repro project to find out it

LingyuCoder avatar Oct 18 '24 07:10 LingyuCoder

at Object.fn (/Users/helium/workspace/pas/node_modules/@xxx/module-federation-typescript/src/plugins/FederatedTypesPlugin.js:70:21)

Seems this error is caused by another plugin which touches the internal objects of tapable, perhaps need a repro project to find out it

Thanks for advice. I found the reason cause that cause this error. As the plugin codes I provided above:

compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
  if (...) callback();
  if (...) callback();
  else callback();
});

callback may executed more than one time in this tapAsync function, and this affect the tapsInRange array at @rspack/lite-tapable/dist/index.js L485. callback is used to notify that async operation is done, so it only need to execute once.

Helium-Z avatar Oct 22 '24 02:10 Helium-Z

at Object.fn (/Users/helium/workspace/pas/node_modules/@xxx/module-federation-typescript/src/plugins/FederatedTypesPlugin.js:70:21)

Seems this error is caused by another plugin which touches the internal objects of tapable, perhaps need a repro project to find out it

Thanks for advice. I found the reason cause that cause this error. As the plugin codes I provided above:

compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compilation, callback) => { if (...) callback(); if (...) callback(); else callback(); }); callback may executed more than one time in this tapAsync function, and this affect the tapsInRange array at @rspack/lite-tapable/dist/index.js L485. callback is used to notify that async operation is done, so it only need to execute once.

Same error, what can i to do to fix this problem ?

HuiWang111 avatar Dec 05 '24 14:12 HuiWang111

at Object.fn (/Users/helium/workspace/pas/node_modules/@xxx/module-federation-typescript/src/plugins/FederatedTypesPlugin.js:70:21)

Seems this error is caused by another plugin which touches the internal objects of tapable, perhaps need a repro project to find out it

Thanks for advice. I found the reason cause that cause this error. As the plugin codes I provided above: compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compilation, callback) => { if (...) callback(); if (...) callback(); else callback(); }); callback may executed more than one time in this tapAsync function, and this affect the tapsInRange array at @rspack/lite-tapable/dist/index.js L485. callback is used to notify that async operation is done, so it only need to execute once.

Same error, what can i to do to fix this problem ?

You can create a new issue and provide a repro project. Not sure whether your error is caused by the same problem here.

LingyuCoder avatar Dec 10 '24 06:12 LingyuCoder