Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

iAPI Router: Prevent a race condition waiting for new styles during client-side navigation - #10

Merged
DAreRodz merged 6 commits into
interactivity-apifrom
fix/iapi-router-styles-race-condition
Apr 3, 2025
Merged

DAreRodz merged 6 commits into
interactivity-apifrom
fix/iapi-router-styles-race-condition

Conversation

@DAreRodz

@DAreRodz DAreRodz commented Apr 1, 2025

Copy link
Copy Markdown
Collaborator

Warning

Developed on top of #9. Wait for that PR to be merged until merging this.

What?

Prevents a potential race condition that could happen while handling styles during client-side navigation. Mentioned in #2 (comment).

Why?

During a client-side navigation, the renderRegions function was wrongly waiting for styles to be ready. A pending style sheet could delay a render and cause an unexpected render after a more recent navigation.

How?

Moving the waiting logic inside regionsToVdom for both styles and js modules. The modules part will be revisited at #6.

@DAreRodz DAreRodz added the type: bug The issue is a confirmed bug. label Apr 1, 2025
@github-actions

github-actions Bot commented Apr 1, 2025 •

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: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>

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

@luisherranz luisherranz left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but I have a couple of questions.

Also, I think we should rethink when actions.prefetch should be resolved. Certainly after the HTML and CSS have been loaded, what I'm not so sure about is the preloading of the scripts. But maybe we can leave that decision for this PR:

@DAreRodz
DAreRodz requested a review from luisherranz April 2, 2025 15:09

@luisherranz luisherranz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thank you very much, David. Great tests, as always 🙂

@DAreRodz

DAreRodz commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator Author

Thanks @luisherranz! Whenever you have time, this PR was built on top of #9. That one also needs a review. 😊

@DAreRodz
DAreRodz changed the base branch from fix/iapi-router-styles-preload-bug to interactivity-api April 3, 2025 10:50
@DAreRodz
DAreRodz merged commit d3b5806 into interactivity-api Apr 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: bug The issue is a confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants