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

Prefetch not working in components with server:defer and top-level await #13297

Closed
1 task
ksolberg opened this issue Feb 22, 2025 · 1 comment
Closed
1 task
Labels
needs triage Issue needs to be triaged

Comments

@ksolberg
Copy link

ksolberg commented Feb 22, 2025

Astro Info

block
Astro                    v5.3.0
Node                     v22.12.0
System                   Windows (x64)
Package Manager          npm
Output                   server
Adapter                  none
Integrations             none

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

No response

Describe the Bug

In the following example only link a works.

All links work if top level await in Deferred.astro is removed.

astro.config.mjs

import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
  output: 'server',
  prefetch: true
});

index.astro

---
import Deferred from '../components/Deferred.astro';
---

<h1>Home</h1>
<p>{new Date().toString()}</p>
<Deferred server:defer link="/about-a"/>	
<Deferred link="/about-b"/>	

Deferred.astro

---
const { link } = Astro.props;

const getMsg = async () => {
  return new Promise ((resolve) => {
    setTimeout(() => {
      resolve(`This is the message for ${link}`);
    }, 100);
  });
}

const res = await getMsg();
---
<a href={link} data-astro-prefetch>{link}</a>

about-a.astro
about-b.astro

<h1>About</h1>
<a href="/">Home</a>

What's the expected result?

Expect prefetch to work for both links, including the one with server:defer and top level-await.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dzimzdt7

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 Feb 22, 2025
@ematipico
Copy link
Member

I tried the reproduction, and the prefetching works as expected, which is the hover strategy.

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants