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

Ensure consistent server route handling by always starting managerBuilder before previewBuilder #19406

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 16 additions & 27 deletions code/lib/core-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,40 +147,29 @@ export async function storybookDevServer(options: Options) {
logConfig('Preview webpack config', await previewBuilder.getConfig(options));
}

const preview = options.ignorePreview
? Promise.resolve()
: previewBuilder.start({
startTime,
options,
router,
server,
});

const manager = managerBuilder.start({
const managerResult = await managerBuilder.start({
startTime,
options,
router,
server,
});

const [previewResult, managerResult] = await Promise.all([
preview.catch(async (err) => {
let previewResult;
if (!options.ignorePreview) {
try {
previewResult = await previewBuilder.start({
startTime,
options,
router,
server,
});
} catch (error) {
await managerBuilder?.bail();
throw err;
}),
manager
// TODO #13083 Restore this when compiling the preview is fast enough
// .then((result) => {
// if (!options.ci && !options.smokeTest) openInBrowser(address);
// return result;
// })
.catch(async (err) => {
await previewBuilder?.bail();
throw err;
}),
]);

// TODO #13083 Remove this when compiling the preview is fast enough
throw error;
}
}

// TODO #13083 Move this to before starting the previewBuilder - when compiling the preview is so fast that it will be done before the browser is done opening
if (!options.ci && !options.smokeTest && options.open) {
openInBrowser(host ? networkAddress : address);
}
Expand Down