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

When using ClientRouter, server island won't run when navigating to a page with island via router #13461

Closed
1 task
SkyfallWasTaken opened this issue Mar 18, 2025 · 4 comments · Fixed by #13481
Closed
1 task
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@SkyfallWasTaken
Copy link

SkyfallWasTaken commented Mar 18, 2025

Astro Info

Astro                    v5.5.3
Node                     v22.11.0
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/vercel
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When navigating to a page with a client router link, server islands don't run and the island is stuck on the forever.

Kailee.s.video.mp4

(don't mind the clicking noises on the video 😅)

Bit more context on the Astro Discord: https://discord.com/channels/830184174198718474/1350777626079399936/1350777626079399936

What's the expected result?

Island loads in.

Link to Minimal Reproducible Example

https://server-islands-bug-repro.vercel.app (code: https://github.com/SkyfallWasTaken/server-islands-bug-repro)

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Mar 18, 2025
@martrapp martrapp added - P2: has workaround Bug, but has workaround (priority) and removed needs triage Issue needs to be triaged labels Mar 21, 2025
@martrapp
Copy link
Member

martrapp commented Mar 21, 2025

Hi @SkyfallWasTaken 👋🏼,

the client router won't re-execute known scripts found since the last full page load. Thus the server island code isn't executed if you visit the page again.

Do you use any special features of the <ClientRouter /> like persisted elements or can you just switch to the View Transition API?

@SkyfallWasTaken
Copy link
Author

SkyfallWasTaken commented Mar 21, 2025

Hi! I do use the router's "preload page on link hover" feature to make things feel fast, so I would rather just use two lines of code to make things Just Work:tm: instead of reimplementing that myself.

Thus the server island code isn't executed if you visit the page again.

I'm not familiar with the Astro codebase, but it might be worth adding the ability to mark scripts as something to run every time you go to the page? Server islands not working properly with the ClientRouter is definitely a bit surprising in my opinion.

@martrapp
Copy link
Member

haha, yes that's surprising.
This is a regression caused by #12985
I'll fix the server islands script.

Regarding prefetch: You can use this feature independent of the client router.

@SkyfallWasTaken
Copy link
Author

Okay, thank you! Will try and switch to View Transitions API :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants