Skip to content

fix(hmr): eagerly recompile on style-only change to prevent stale slots render#15953

Merged
matthewp merged 1 commit intowithastro:mainfrom
Desel72:fix/issue-15925
Mar 17, 2026
Merged

fix(hmr): eagerly recompile on style-only change to prevent stale slots render#15953
matthewp merged 1 commit intowithastro:mainfrom
Desel72:fix/issue-15925

Conversation

@Desel72
Copy link
Copy Markdown
Contributor

@Desel72 Desel72 commented Mar 17, 2026

Changes

  • When a style-only change triggers HMR, eagerly recompile the Astro file instead of deleting its compile metadata
  • Previously, deleting the metadata caused the next SSR request (page refresh) to re-compile via Vite's plugin pipeline, which returned stale/transformed code — breaking Astro.slots.render() with callback args
  • Components using Astro.slots.render("default", [...args]) now render correctly after style edits + page refresh

Fixes #15925

Testing

  • Added hmr-slots-render.test.js with a fixture that reproduces the exact scenario: a component using Astro.slots.render with callback args, style-only edits, and page refresh
  • Verifies rendered output contains no raw HTML source (data-astro-cid) after multiple style changes

Docs

No docs needed — this is a bug fix for existing behavior.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: cd14c1e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 17, 2026
@Desel72 Desel72 force-pushed the fix/issue-15925 branch 2 times, most recently from 1f5cc97 to dc41cb3 Compare March 17, 2026 03:29
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing Desel72:fix/issue-15925 (cd14c1e) with main (f5cc2b0)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (4c54123) during the generation of this report, so f5cc2b0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Desel72
Copy link
Copy Markdown
Contributor Author

Desel72 commented Mar 17, 2026

Hi @matthewp, I hope you are doing well.
Could you please review this PR?

@matthewp matthewp merged commit 7eddf22 into withastro:main Mar 17, 2026
27 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Mar 17, 2026
@Desel72
Copy link
Copy Markdown
Contributor Author

Desel72 commented Mar 17, 2026

Thanks @matthewp

@chaegumi
Copy link
Copy Markdown
Contributor

chaegumi commented Mar 22, 2026

This issue still persists on my end.

image I made a casual change to a file, and after saving it— [vite] program reload —the page ended up looking exactly as shown in the image. I have to run dev again to restore it to normal.

dadezzz pushed a commit to dadezzz/ice-notes that referenced this pull request Mar 22, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.0.5` → `6.0.6`](https://renovatebot.com/diffs/npm/astro/6.0.5/6.0.6) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.0.6?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.0.5/6.0.6?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.0.6`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#606)

[Compare Source](https://github.com/withastro/astro/compare/astro@6.0.5...astro@6.0.6)

##### Patch Changes

- [#&#8203;15965](withastro/astro#15965) [`2dca307`](withastro/astro@2dca307) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes client hydration for components imported through Node.js subpath imports (`package.json#imports`, e.g. `#components/*`), for example when using the Cloudflare adapter in development.

- [#&#8203;15770](withastro/astro#15770) [`6102ca2`](withastro/astro@6102ca2) Thanks [@&#8203;jpc-ae](https://github.com/jpc-ae)! - Updates the `create astro` welcome message to highlight the graceful dev/preview server quit command rather than the kill process shortcut

- [#&#8203;15953](withastro/astro#15953) [`7eddf22`](withastro/astro@7eddf22) Thanks [@&#8203;Desel72](https://github.com/Desel72)! - fix(hmr): eagerly recompile on style-only change to prevent stale slots render

- [#&#8203;15916](withastro/astro#15916) [`5201ed4`](withastro/astro@5201ed4) Thanks [@&#8203;trueberryless](https://github.com/trueberryless)! - Fixes `InferLoaderSchema` type inference for content collections defined with a loader that includes a `schema`

- [#&#8203;15864](withastro/astro#15864) [`d3c7de9`](withastro/astro@d3c7de9) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Removes temporary support for Node >=20.19.1 because Stackblitz now uses Node 22 by default

- [#&#8203;15944](withastro/astro#15944) [`a5e1acd`](withastro/astro@a5e1acd) Thanks [@&#8203;fkatsuhiro](https://github.com/fkatsuhiro)! - Fixes SSR dynamic routes with `.html` extension (e.g. `[slug].html.astro`) not working

- [#&#8203;15937](withastro/astro#15937) [`d236245`](withastro/astro@d236245) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes an issue where HMR didn't correctly work on Windows when adding/changing/deleting routes in `pages/`.

- [#&#8203;15931](withastro/astro#15931) [`98dfb61`](withastro/astro@98dfb61) Thanks [@&#8203;Strernd](https://github.com/Strernd)! - Fix skew protection query params not being applied to island hydration `component-url` and `renderer-url`, and ensure query params are appended safely for asset URLs with existing search/hash parts.

- Updated dependencies \[]:
  - [@&#8203;astrojs/markdown-remark](https://github.com/astrojs/markdown-remark)@&#8203;7.0.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43Ni4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzYuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: Renovate Bot <renovate@zarantonello.dev>
Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
@Desel72 Desel72 deleted the fix/issue-15925 branch March 23, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v6] Components not rendered on page refresh using the dev server

3 participants