[Bug]: broken caused by `@rspack/lite-tabable` reading a property from `undefined`
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
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.
please provide full error report, the reason most lie in plugin use some unsupported hook so we need more error info
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:
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:
reproduction project: https://github.com/swalker326/ze-workspace
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
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
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.
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(); });
callbackmay executed more than one time in this tapAsync function, and this affect thetapsInRangearray at@rspack/lite-tapable/dist/index.js L485.callbackis 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 ?
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(); });
callbackmay executed more than one time in this tapAsync function, and this affect thetapsInRangearray at@rspack/lite-tapable/dist/index.js L485.callbackis 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.