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

Composition: Fix refs not loading when there's multiple #26356

Merged
merged 7 commits into from Mar 8, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Mar 6, 2024

Closes #26288

What I did

  • analysed the issue linked above and found that all the refs work, but when they resolve and set state, they race against each other and end up overriding the state.refs data.
  • I modified the code so refs resolve in sequence, and set in that sequence.
  • the order in which they are resolved in the same as they are setup and so also visually.

I also verified that the url field of a ref does in fact support a relative path!

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

I manually tested this using a special repro I setup (and will attach a zip for here).
repro-with-many-refs.zip

I copied the contents of ./code/ui/manager/dist into {repro}/node_modules/@storybook/manager/dist, and ran storybook.

Before copying over, the storybook only loaded 1 or 2 refs. after the copy, all refs load in nicely, with clearly demonstrating the sequence happening. Honestly I kinda liked the effect.

composition-multiple-load.mov

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Copy link

nx-cloud bot commented Mar 6, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4e723fe. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen ndelangen changed the title load refs in sequence, await writing to state Composition: Fix refs not loading Mar 6, 2024
@ndelangen ndelangen changed the title Composition: Fix refs not loading Composition: Fix refs not loading when there's multiple Mar 6, 2024
@ndelangen ndelangen marked this pull request as ready for review March 6, 2024 20:06
@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Mar 7, 2024

I think lines 175 and 176 needs to be adjusted as well to await them and therefore, to be correct, changeRefVersion had to be async as well. I don't know which other code places has to be adjusted then to propagate this change.

@ndelangen
Copy link
Member Author

@valentinpalkovic thank you, that's helpful. I've adjusted the code.

@ndelangen ndelangen requested a review from JReinhold March 8, 2024 09:00
code/lib/manager-api/src/modules/refs.ts Outdated Show resolved Hide resolved
code/lib/manager-api/src/modules/refs.ts Outdated Show resolved Hide resolved
@ndelangen ndelangen merged commit d135d12 into next Mar 8, 2024
56 checks passed
@ndelangen ndelangen deleted the norbert/fix-composition-loading-problem branch March 8, 2024 12:51
@github-actions github-actions bot mentioned this pull request Mar 8, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Storybook 8 Composition Flakiness
3 participants