-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Partytown scripts break ViewTransition #11033
Comments
The Partytown snippet is supposed to be loaded only once, but when the View Transitions API gets activated, the <script> element containing this snippet is recreated on every transition. astro/packages/integrations/partytown/src/index.ts Lines 28 to 38 in 6f94890
I decided to comment out the line adding SELF_DESTRUCT_ON_VIEW_TRANSITION to the script and see what happens. The outcome is: That's probably expected. We should let Partytown know there may be new scripts added by dispatching new CustomEvent('ptupdate'). I did so, and nothing happened. Under certain conditions, Partytown may need an <iframe> element to be present on the page. It's true for my local environment, and when a view transition happens, this <iframe> is removed from the DOM. We should persist it somehow 🤔 EDIT: |
@V3RON thanks for doing the research! Would you mind sending a PR? |
I intend to do so 😉 |
@matthewp If so, then this commit should be all we need. It moves the Is there any edge-case I should be aware of? 🤔 |
thanks @V3RON! tested this commit in my local machine, and can confirm that partytown is no longer crashing. I can also see that the service worker is re-initialized on route change. I'm not sure if that is the intended behavior for partytown. the only thing I can think of is comparing it to nuxtjs or nextjs, would that be helpful? EDIT: |
Sounds perfect to me. |
It's not, but there is no way to move |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Scripts with partytown break when transitioning between routes with ViewTransitions.
Console error (on multiple browsers):
This can be shown in the Minimal Reproducible Example attached.
What's the expected result?
Partytown webworker should not break when transitioning routes with ViewTransition
Link to Minimal Reproducible Example
https://astro-viewtransition-partytown-bug.vercel.app/
Code
Repo: https://github.com/dsegovia90/astro-viewtransition-partytown-bug
Partytown script: https://github.com/dsegovia90/astro-viewtransition-partytown-bug/blob/57ac9a6a624284e57bd4163feb553d563a7772dd/src/layouts/Layout.astro#L22C3-L27C12
Participation
The text was updated successfully, but these errors were encountered: