Skip to content

Storybook: Handle production module load failures - #81867

Open
ciampo wants to merge 1 commit into
trunkfrom
codex/fix-storybook-module-load-failures
Open

Storybook: Handle production module load failures#81867
ciampo wants to merge 1 commit into
trunkfrom
codex/fix-storybook-module-load-failures

Conversation

@ciampo

@ciampo ciampo commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What?

Makes the production Storybook more resilient to intermittent dynamic module load failures.

Why?

The production site can request hundreds of story dependencies at once. A single transient GitHub Pages or CDN failure causes the complete story import to fail, even when the story module itself returns 200.

How?

  • Disables Vite's eager JavaScript module preloading so the browser discovers the dependency graph incrementally.
  • Handles Vite's vite:preloadError with one guarded full-page reload.
  • Lets a repeated failure within 60 seconds surface normally instead of creating a reload loop.

See Vite's load error handling guidance.

Testing Instructions

  1. Run npm run storybook:build.
  2. Serve storybook/build and open /?path=/story/design-system-components-menu--default.
  3. Confirm that the Menu story renders.
  4. In the preview iframe, dispatch window.dispatchEvent( new Event( 'vite:preloadError', { cancelable: true } ) );.
  5. Confirm that the full Storybook reloads once and the Menu story renders again.
  6. Dispatch the same event again within 60 seconds.
  7. Confirm that the page does not reload again.

Testing Instructions for Keyboard

Not applicable. This changes Storybook asset loading and does not change keyboard interaction.

Screenshots or screencast

Here's what the typical failure looks like

Screenshot 2026-08-20 at 12 22 26

Use of AI Tools

This pull request was implemented with Codex. The investigation used browser inspection, a HAR export, generated build analysis, and local automated verification. The author reviewed the resulting changes.

@ciampo ciampo self-assigned this Aug 20, 2026
@ciampo ciampo added [Type] Bug An existing feature does not function as intended Storybook Storybook and its stories for components labels Aug 20, 2026
@ciampo
ciampo requested review from a team, Mamaduka and manzoorwanijk August 20, 2026 10:22
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.74 MB

compressed-size-action

@ciampo
ciampo marked this pull request as ready for review August 20, 2026 10:23
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 4559721.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32358276178
📝 Reported tests:

inserts a block in proper place after having clicked `Browse All` from block appender in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/blocks?per_page=100&status=publish%2Cfuture%2Cdraft%2Cpending%2Cprivate%2Ctrash
    - user-agent: Playwright/1.62.1 (x64; ubuntu 24.04) node/20.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 8cca09d5f1
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1787394238%7CHrGs9QCuvEOnzmaVYfjDLxHdn2jJM1SDxplEoisGFPm%7C0dba0995218fd4f4215c94f3c358ced7eec0aef5ff81bba82aca159cefb579b5; wp-settings-time-1=1787221439

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at RequestUtils.deleteAllBlocks (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/blocks.ts:23:28)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:11:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storybook Storybook and its stories for components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant