Skip to content

fix(link): Prefetch redirects to error pages. Fixes #5474 #5817

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

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

iamriajul
Copy link
Contributor

@iamriajul iamriajul commented Feb 4, 2024

Overview

Fixes: #5474

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos

Description

This PR fixes the bug by adding a flag to the loadClientData function, and update handlePrefetch in link-component to use the flag to indicate that the call is intended to just prefetch not actual navigation, So in-case the route does occur unexpected error or doesn't exist it shouldn't redirect to the page.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

netlify bot commented Feb 4, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 3fb3f30

@@ -48,7 +48,10 @@ export const Link = component$<LinkProps>((props) => {
prefetchSymbols(url.pathname);

if (elm.hasAttribute('data-prefetch')) {
loadClientData(url, elm, { prefetchSymbols: false });
loadClientData(url, elm, {
prefetchSymbols: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a little bit confused about prefetchSymbols being false!

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this specifically to fetch the data separately? The symbols are being fetched elsewhere.

Copy link
Contributor Author

@iamriajul iamriajul Feb 4, 2024

Choose a reason for hiding this comment

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

Isn't this specifically to fetch the data separately?

I don't know really. Currently the prefetch only data. and symbols are prefetched via the service-worker maybe.

Copy link
Member

Choose a reason for hiding this comment

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

Actually it's done two lines above this call

Copy link
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

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

I was a little worried that there might be other places that prefetch data that would need this flag, but it's indeed only in this place. Nice concise solution!

LGTM

@wmertens wmertens merged commit 0f74db1 into QwikDev:main Feb 4, 2024
kodiakhq bot referenced this pull request in ascorbic/unpic-img Feb 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@builder.io/qwik](https://qwik.builder.io/) ([source](https://togithub.com/BuilderIO/qwik/tree/HEAD/packages/qwik)) | [`1.4.3` -> `1.4.4`](https://renovatebot.com/diffs/npm/@builder.io%2fqwik/1.4.3/1.4.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@builder.io%2fqwik/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@builder.io%2fqwik/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@builder.io%2fqwik/1.4.3/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@builder.io%2fqwik/1.4.3/1.4.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>BuilderIO/qwik (@&#8203;builder.io/qwik)</summary>

### [`v1.4.4`](https://togithub.com/BuilderIO/qwik/releases/tag/v1.4.4)

[Compare Source](https://togithub.com/BuilderIO/qwik/compare/v1.4.3...v1.4.4)

#### What's Changed

-   feat(vite): make linting op-out by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5801](https://togithub.com/BuilderIO/qwik/pull/5801)
-   fix(core): assign refs without reactivity during SSR by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5802](https://togithub.com/BuilderIO/qwik/pull/5802)
-   fix(docs): correct minor typos by [@&#8203;kylerush](https://togithub.com/kylerush) in [https://github.com/BuilderIO/qwik/pull/5804](https://togithub.com/BuilderIO/qwik/pull/5804)
-   chore(starters): update 🐼 PandaCSS integration starter dev dependency by [@&#8203;mrhoodz](https://togithub.com/mrhoodz) in [https://github.com/BuilderIO/qwik/pull/5806](https://togithub.com/BuilderIO/qwik/pull/5806)
-   fix(scoped styles): [@&#8203;container](https://togithub.com/container) block by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5813](https://togithub.com/BuilderIO/qwik/pull/5813)
-   chore: ci e2e: single worker and longer timeout by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5814](https://togithub.com/BuilderIO/qwik/pull/5814)
-   fix(link): Prefetch redirects to error pages. Fixes [#&#8203;5474](https://togithub.com/BuilderIO/qwik/issues/5474) by [@&#8203;iamriajul](https://togithub.com/iamriajul) in [https://github.com/BuilderIO/qwik/pull/5817](https://togithub.com/BuilderIO/qwik/pull/5817)
-   chore: publish qwik-react with types by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5819](https://togithub.com/BuilderIO/qwik/pull/5819)
-   fix: Fix input reactivity in `useResource$()` tutorial by [@&#8203;alexcsandru](https://togithub.com/alexcsandru) in [https://github.com/BuilderIO/qwik/pull/5818](https://togithub.com/BuilderIO/qwik/pull/5818)
-   docs: fix qwik-nutshell example by [@&#8203;ozanmakes](https://togithub.com/ozanmakes) in [https://github.com/BuilderIO/qwik/pull/5824](https://togithub.com/BuilderIO/qwik/pull/5824)
-   chore(starters): update 🐼 PandaCSS integration starter dev dependency by [@&#8203;mrhoodz](https://togithub.com/mrhoodz) in [https://github.com/BuilderIO/qwik/pull/5825](https://togithub.com/BuilderIO/qwik/pull/5825)
-   chore: 1.4.4 by [@&#8203;wmertens](https://togithub.com/wmertens) in [https://github.com/BuilderIO/qwik/pull/5828](https://togithub.com/BuilderIO/qwik/pull/5828)

#### New Contributors

-   [@&#8203;kylerush](https://togithub.com/kylerush) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5804](https://togithub.com/BuilderIO/qwik/pull/5804)
-   [@&#8203;alexcsandru](https://togithub.com/alexcsandru) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5818](https://togithub.com/BuilderIO/qwik/pull/5818)
-   [@&#8203;ozanmakes](https://togithub.com/ozanmakes) made their first contribution in [https://github.com/BuilderIO/qwik/pull/5824](https://togithub.com/BuilderIO/qwik/pull/5824)

**Full Changelog**: QwikDev/qwik@v1.4.3...v1.4.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm on sunday" (UTC), 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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ascorbic/unpic-img).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐞] Prefetch redirects to error pages.
2 participants