-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Bug]: Error when building storybook after upgrading to 8.2 #28576
Comments
** Disclaimer** This information might be inaccurate, due to it being generated automatically async function loader(this: LoaderContext, content: string, map: any) {
const callback = this.async();
const options = this.getOptions();
const id = this.resourcePath;
const sourceCode = await fs.readFile(id, 'utf-8');
try {
const makeTitle = (userTitle: string) => userTitle || 'default';
const csf = loadCsf(content, { makeTitle }).parse();
const csfSource = loadCsf(sourceCode, { makeTitle }).parse();
enrichCsf(csf, csfSource, options);
const formattedCsf = formatCsf(csf, { sourceMaps: true, inputSourceMap: map }, content);
if (typeof formattedCsf === 'string') {
callback(null, formattedCsf, map);
} else {
callback(null, formattedCsf.code, formattedCsf.map);
}
} catch (err: any) {
// This can be called on legacy storiesOf files, so just ignore
// those errors. But warn about other errors.
if (!err.message?.startsWith('CSF:')) {
console.warn(err.message);
}
callback(null, content, map);
}
} This ensures the callback is only called once, preventing the References/code/lib/csf-plugin/src/webpack-loader.ts
|
As the error about a callback called multiple times seems to be triggered by another error, I also tried to modify https://github.com/storybookjs/storybook/blob/v8.2.2/code/lib/csf-plugin/src/webpack-loader.ts#L34 to log the whole error instead of only the message (
And the starting call at |
Same thing happening on my end as well, exact same error too Removing the |
@stof seems like the issue happens in this line in NormalModule from webpack: Could you try to check what's being passed to it and why is Can you also share more context in what your main.js file looks like? |
@TylerNRobertson do I understand correctly that you had a main.js file with something like: import { StorybookConfig } from '@storybook/react-vite'
const config: StorybookConfig = {
// ...
addons: [
'@storybook/preview-api', <-- did you have this?
]
}
export default config If so, why would you have it? Such package was never intended to be used like that. Can you share as much detail as possible in your project and provide a reproduction, so we can look into this further? |
@yannbf I just removed the package altogether and opted to use react state. Also Just can't show the story source previews for now but that's not critical in my case. However unsure why both those addons don't get bundled correctly |
@TylerNRobertson thanks for elaborating! Seems like both of you had This would help us immensely! |
Definitely @yannbf heres out
|
here is my const path = require('node:path')
const encoreConfig = require('../../webpack.config')
const babelExclude = encoreConfig.module.rules.find(rule => rule.test instanceof RegExp && rule.test.test('foo.js')).exclude
/**
* @type {import('@storybook/html-webpack5').StorybookConfig}
*/
module.exports = {
features: {
postcss: false
},
stories: ['../../assets/scss/**/*.@(common|app).stories.js', '../../assets/scss/**/*.@(common|app).mdx', '../../assets/scss/*.mdx'],
addons: [
'@whitespace/storybook-addon-html',
'@storybook/addon-a11y',
'@storybook/addon-essentials',
'@storybook/addon-storysource',
'storybook-addon-mock'
],
webpackFinal: async (config) => {
config.resolve.fallback.crypto = false
config.module.rules.push({
test: /\.scss$/,
use: ['style-loader', 'css-loader', {
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [path.resolve(__dirname, '../../node_modules')]
}
}
}],
include: path.resolve(__dirname, '../scss/')
})
const jsRule = config.module.rules.find(rule => rule.test instanceof RegExp && rule.test.test('foo.js'))
if (jsRule) {
jsRule.exclude = babelExclude
}
return config
},
framework: {
name: '@storybook/html-webpack5',
options: {}
},
env: (config) => ({
...config,
DEVICE: 'desktop'
})
} When adding some console logging in webpack's NormalModule in
This I tried commenting all addons except |
@valentinpalkovic I wonder if this is related to the sourcemap fixes you added in 8.2? |
@shilman Can definitely be related! I am taking a look! |
+1 |
I have figured out the issue, and I will provide a fix soon. We will prepare a hotfix release on Monday at the latest |
@shilman This PR will fix the issue: @ckifer, @stof, @TylerNRobertson Could you please try out the following canary version?: |
Describe the bug
Our storybook setup was working fine with Storybook 8.1. However, when trying to upgrade to 8.2, I'm getting this report:
The error location in
@storybook/csf-plugin/dist/webpack-loader.js
corresponds to the call in https://github.com/storybookjs/storybook/blob/v8.2.2/code/lib/csf-plugin/src/webpack-loader.ts#L36Apparently
callback
is caused multiple time which is forbidden byloader-runner
. Looking at the code quickly, I suspect this might happen when an error is thrown during the execution of the callback itself (for a successful processing) as they are inside thetry
block: https://github.com/storybookjs/storybook/blob/v8.2.2/code/lib/csf-plugin/src/webpack-loader.ts#L25-L29Reproduction link
none yet
Reproduction steps
No response
System
Additional context
No response
The text was updated successfully, but these errors were encountered: