Core: bail preview builder on failure #19849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: N/A
What I did
For some reason, even when Webpack fails (e.g. wrong main.js config), the preview may continue to print to stdout, which can affect output when we catch this error and process those errors (e.g. telemetry) gets overwritten by preview progress output. Therefore, we should bail the preview too.
An example to get into this situation is using a CRA project without @storybook/preset-create-react-app
The user experience is the following:
- The Storybook server says `WARN Force closed manager build` in the terminal - If crashReports were never answered, the telemetry prompts the user "would you like to send reports". However, immediately after that happens, Webpack continues with preview's progress, which in turn, ovewrites the stdout, therefore never showing the telemetry prompt - Because there is a prompt, the process is hanging, but the user doesn't even know why as they don't see the actual message. Only after pressing either Y, N or Ctrl+C, the process continues and the failures are shown. - This won't happen again in case users responded with Y or N, because that answer is saved in the cache.
How does it look like?
So the fix now interrupts the preview process output, therefore showing the prompt correctly:
And after the prompt is answered (and answer is cached), the other times the failure happens, users will get the errors directly:
How to test
If your answer is yes to any of these, please make sure to include it in your PR.