Skip to content

fix(astro): recover island hydration from transient import failures#16412

Merged
ematipico merged 6 commits intowithastro:mainfrom
0xbejaxer:fix-16341-hydration-recovery
May 6, 2026
Merged

fix(astro): recover island hydration from transient import failures#16412
ematipico merged 6 commits intowithastro:mainfrom
0xbejaxer:fix-16341-hydration-recovery

Conversation

@0xbejaxer
Copy link
Copy Markdown
Contributor

@0xbejaxer 0xbejaxer commented Apr 20, 2026

Summary

  • add astro-island import retry handling with a hash-based retry specifier so transient hydration module import failures can recover
  • dispatch a cancelable astro:hydration-error event with error context and keep default logging only when the event is not prevented
  • add an E2E regression fixture/test that validates recovery after one failed import and verifies persistent failures emit the event without unhandled page errors

Validation

Fixes #16341.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

🦋 Changeset detected

Latest commit: 2ae3eec

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 Apr 20, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 20, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing 0xbejaxer:fix-16341-hydration-recovery (2ae3eec) with main (15fc3f6)1

Open in CodSpeed

Footnotes

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

@0xbejaxer
Copy link
Copy Markdown
Contributor Author

Small update now that CI is fully green.

This PR fixes #16341 by handling island hydration import failures in astro-island with:

  • one retry path for failed component/renderer dynamic imports
  • a cancelable astro:hydration-error event with { error, componentUrl }
  • default console logging only when the event is not prevented
  • error handling in the directive callback path to avoid unhandled rejection noise

Two follow-up commits were needed during CI hardening:

  • f15add9ecf: sync lockfile for the new e2e fixture
  • 47bd822e41: stabilize the new retry e2e by waiting for hydration before asserting click behavior

All checks are now passing.

@0xbejaxer
Copy link
Copy Markdown
Contributor Author

Hi maintainers — friendly ping on this one whenever you have time.

This PR addresses the hydration import failure recovery path discussed in the issue and includes e2e coverage for both retry-success and persistent-failure event behavior.

If there’s any part you’d like reworked (implementation or test shape), I can update quickly.

0xbejaxer added a commit to 0xbejaxer/astro that referenced this pull request Apr 21, 2026
Trigger a fresh workflow run for PR withastro#16412 after an unrelated flaky Cloudflare development e2e failure on windows.

Made-with: Cursor
Retry failed hydration imports with a cache-busting specifier and emit a cancelable astro:hydration-error event so applications can recover without unhandled rejection noise.

Made-with: Cursor
Add the new e2e fixture importer to pnpm-lock.yaml so frozen-lockfile CI installs succeed.

Made-with: Cursor
Wait for island hydration before clicking in the retry test to avoid timing-dependent failures on slower CI runners.

Made-with: Cursor
Trigger a fresh CI run to verify the unrelated lint/typecheck failure is reproducible.

Made-with: Cursor
Trigger a fresh workflow run for PR withastro#16412 after an unrelated flaky Cloudflare development e2e failure on windows.

Made-with: Cursor
@0xbejaxer 0xbejaxer force-pushed the fix-16341-hydration-recovery branch from d9da665 to 622ad51 Compare April 22, 2026 10:40
Copy link
Copy Markdown
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

Let's make this just an event, no retries.

Comment thread .changeset/five-pans-applaud.md Outdated
@@ -0,0 +1,5 @@
---
'astro': patch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a new feature so should be minor.

Also make the changeset a little more in-depth, show a code example of how you might use this.

Copy link
Copy Markdown
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

please make this a minor change

@matthewp matthewp added this to the 6.3 milestone May 1, 2026
Comment thread .changeset/five-pans-applaud.md Outdated
@github-actions github-actions Bot added the semver: minor Change triggers a `minor` release label May 6, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@ematipico ematipico dismissed stale reviews from matthewp and github-actions[bot] May 6, 2026 09:56

Addressed

@ematipico ematipico merged commit ba2d2e3 into withastro:main May 6, 2026
26 of 27 checks passed
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) semver: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

astro-island: no error event, retry, or recovery when hydration import() fails

3 participants