8000 fix: update_branch with (anchor).data possible undefined on ios devices by matteobattista · Pull Request #15851 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content

fix: update_branch with (anchor).data possible undefined on ios devices #15851

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 4 commits into from
May 15, 2025

Conversation

matteobattista
Copy link
Contributor

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link
changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: 2caf059

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

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@15851

@paoloricciuti
Copy link
Member

I don't think this is not the right fix, data needs to be there during hydration, if it's not there we can't just return without doing anything. This is probably some extension messing with the dom or something similar.

If you do want to work on this we also need a test for it tho.

@matteobattista
Copy link
Contributor Author
matteobattista commented Apr 30, 2025

Hi @paoloricciuti,
the PR is related to this issue: #15819 maybe i can refactor with:
if (data === undefined) return;

@paoloricciuti
Copy link
Member

Hi @paoloricciuti, the PR is related to this issue: #15819 maybe i can refactor with: if (data === undefined) return;

I'll try to take a look later, no tests are failing because generally the data it's there but I have the feeling that this will break in case there's malformed html...the app might render but the whole hydration mechanism will fail and it will be unresponsive.

@matteobattista
Copy link
Contributor Author

Hi @paoloricciuti , just to share a possible lead — if it helps:
The issue might be caused by a Cloudflare feature called "Mirage", which injects the following scripts into the HTML during edge processing:

<script type="text/javascript">
//<![CDATA[
window.__mirage2 = {petok: "..."};
//]]>
</script>
<script src="https://ajax.cloudflare.com/cdn-cgi/scripts/04b3eb47/cloudflare-static/mirage2.min.js"></script>

This is not part of the SvelteKit app itself — it’s automatically added by Cloudflare when the Mirage optimization is enabled in the dashboard under Speed > Optimization > Mirage.

So if anyone else is seeing unexpected <script> tags inside HTML elements (like inside a <div>), this could be the reason.

Let me know if this helps clarify things!

@Rich-Harris
8000
Copy link
Member

We'd need a test before we could merge this, otherwise it's very likely we'll regress. Can you reproduce the issue?

@Rich-Harris Rich-Harris marked this pull request as draft May 13, 2025 00:31
@matteobattista
Copy link
Contributor Author

Thank you for considering my post 🙏🏻 ...I understand that making such a change could solve one problem but potentially introduce others.

To reproduce the issue, I believe you can follow what's already described in the other report: #15819.

On my end, I was able to work around it by disabling the option in Cloudflare that was causing it — as shown in the attached screenshot:

Screenshot 2025-05-13 alle 10 21 58

Under Speed > Optimization > Image Optimization > Mirage > (off)

@svelte-docs-bot
Copy link

Copy link
Member
@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

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

added some tests and tweaked the implementation to make the error explicit at the point where we expect the hydration comment — thank you!

@Rich-Harris Rich-Harris marked this pull request as ready for review May 15, 2025 15:52
@Rich-Harris Rich-Harris merged commit a5a0b49 into sveltejs:main May 15, 2025
9 checks passed
@github-actions github-actions bot mentioned this pull request May 15, 2025
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.

3 participants
0