Skip to content

Commit

Permalink
Merge pull request #19406 from storybookjs/jeppe/enforce-manager-buil…
Browse files Browse the repository at this point in the history
…der-first

Ensure consistent server route handling by always starting `managerBuilder` before `previewBuilder`
  • Loading branch information
ndelangen authored Oct 12, 2022
2 parents 0f54659 + dd20efb commit c3bb8b7
Showing 1 changed file with 16 additions and 27 deletions.
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

0 comments on commit c3bb8b7

Please sign in to comment.