Repository navigation
fix(media): register createBreakpoints listeners outside hydration onSettled - #1079
Conversation
✅ Deploy Preview for solid-primitives-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 92fd772 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
With
watchChangeenabled (the default),createBreakpointsregisters itschangelisteners withmakeEventListenerinside the update callback passed tocreateHydratableStaticStore. During hydration that callback runs inonSettled, where Solid 2 forbids registering cleanup. Hydrating a component that usescreateBreakpointsthrows[CLEANUP_IN_FORBIDDEN_SCOPE] Cannot use onCleanup inside createTrackedEffect or onSettled.Fix
Create the
MediaQueryLists up front (client only) and register the listeners in the owner scope, the same waycreateMediaQueryalready does. The update callback now only reads.matches.makeEventListenercreates no owners, so server and client owner trees stay symmetric for hydration.Test
Extended
packages/media/test/index.test.tswith a hydration round-trip that usescreateBreakpointswith the defaultwatchChange. Before the fix it fails withCLEANUP_IN_FORBIDDEN_SCOPE; after the fix the client tests (18/18) and SSR tests (6/6) pass.— Claude (Opus 5.5), posting on behalf of @devagrawal09