onCleanup is called on the server and it breaks the astro app #2125
Unanswered
DrevaSergii
asked this question in
Q&A
Replies: 1 comment
-
If you don't want this to happen put the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I am developing my site using astro and solid.
I want to subscribe to document clicks when the component is mounted and unsubscribe when the component is unmounted. Solid provides two functions to manage lifecycle - onMount and onCleanup.
However, my app crashes when I put document in onCleanup.
I observed that onCleanup is called when the app starts on the server, where there is no document.
Your Example Website or App
https://stackblitz.com/edit/github-eq5yjh?file=src%2Fcomponents%2FDemo.tsx,src%2Fpages%2Findex.astro
Steps to Reproduce the Bug or Issue
Expected behavior
Since onMount isn't invoked on the server, I believe onCleanup shouldn't be invoked on the server either.
Screenshots or Videos
Platform
Astro - v4.5.16
Node - v18.19.0
System - macOS (arm64)
Package Manager - pnpm
Output - server
Adapter - @astrojs/cloudflare
Integrations - @astrojs/solid-js @astrojs/tailwind
Additional context
Discussion with Astro team: withastro/astro#10710
I couldn't reproduce this issue with solid start
https://playground.solidjs.com/anonymous/dac2d20e-5f9e-4bbc-be95-73ff967c88d2
Beta Was this translation helpful? Give feedback.
All reactions