onMount randomly not called

What could be reasons why an onMount effect is not called at all in a completely random pattern? It runs fine in like 19 of 20 times. Other effects still run on the same request, while the onMount doesnt 🤯. I am getting this in the latest solid 1.8.21.
74 Replies
fabiospampinato
fabiospampinato•5mo ago
What comes to mind is that either it's getting disposed, or it's getting suspended, or something weird is happening like throwing inside a cleanup handler or something for the clenaup case you can check if a cleanup there is instead always called for suspense I guess maybe you can check if a sibling memo is instead always called
REEEEE
REEEEE•5mo ago
I ran into some issue with 1.8.21 too (and 1.8.20) I suspect it's because of the hydration changes, but I have no clue how everything connects
Katja (katywings)
Katja (katywings)OP•5mo ago
like so? 🤔 - some parent - component with failing onMount - different component with memo
Jasmin
Jasmin•5mo ago
1.8.20 was buggy with <Dynamic>, this got fixed in 1.8.21. But it seems like there is another bug? :thinkies: https://discord.com/channels/722131463138705510/1273013394588565620 this one here
REEEEE
REEEEE•5mo ago
The issue I had was related to context Actually it could've been a solid-primitives issue. I was using the createBreakpoints primitive and I just noticed it's doing changes depending on hydration. Although it was working in 1.8.19
fabiospampinato
fabiospampinato•5mo ago
- some parent - some component - failing onMount - sibling memo the last 2 are on the same level in theory, I don't know why they are rendered like that
Katja (katywings)
Katja (katywings)OP•5mo ago
sibling effects run 🥴
fabiospampinato
fabiospampinato•5mo ago
that's very weird bug in Solid then I guess
Katja (katywings)
Katja (katywings)OP•5mo ago
I sadly dont have the time to debug this at the moment 🙈 e.g: - component A onMount is skipped - deep component B effect runs
fabiospampinato
fabiospampinato•5mo ago
It's better to try it with a sibling effect because the deeper effect could be under a root, under a separate owner, who knows
Razboy20
Razboy20•5mo ago
I'm experiencing this where a navbar component in the root of a router isn't executing onMount or createEffect statements like 50% of the time which isn't making much sense... but state changes coming from a store given by a provider are being reactive inside of the component?
Katja (katywings)
Katja (katywings)OP•5mo ago
@ryansolid could this be somehow related to the recent hydration changes? 🤔 Okay, just checked this, when the bug happens it skips all effects of said component, not only the onMount. And the component function itself is not skipped (e.g. console.logs in the component function are executed) Just in case, this is the component where it is happening: https://codeberg.org/nitropage/nitropage/src/commit/bab5a12117781be480b7b4504d4416d64832db3c/packages/nitropage/src/components/admin/index.tsx#L36
fabiospampinato
fabiospampinato•5mo ago
worth checking now if a sibling memo is skipped too
Joe Pea
Joe Pea•4mo ago
I wonder if this is related to what I've been experiencing in https://discord.com/channels/722131463138705510/910635844119982080/1277514473611202581 and possibly https://discord.com/channels/722131463138705510/1273412699530858527 (EDIT: the second one seems like another issue)
Katja (katywings)
Katja (katywings)OP•4mo ago
Found a temporary workaround by reloading the page, if the effect did not run before document onload. Not happy about this but remarkable times sometimes ask for remarkable workarounds I guess 🙈. (https://codeberg.org/nitropage/nitropage/commit/63dd2ac23c25f4706985dc396b4d2a849294661e) Okay this bug is worse than i thought... hovering or clicking on a link during hydration, also skips all effects 🤯
Jasmin
Jasmin•4mo ago
waiit that's what's happening in the solid docs too! if you hover over a link quickly after loading the page it 100% fails hydrating
Jasmin
Jasmin•4mo ago
Katja (katywings)
Katja (katywings)OP•4mo ago
We really need some @ryansolid magic here 😆
Joe Pea
Joe Pea•4mo ago
Not sure if this provides any good clue, but I was able to trigger effects not running with this: https://github.com/solidjs/solid-start/issues/1614
REEEEE
REEEEE•4mo ago
haha I wasn't crazy! I'm pretty sure some part of contexts in ssr broke with this too
ryansolid
ryansolid•4mo ago
It is possible this is related to the changes. Anyway to check against 1.8.19?
Jasmin
Jasmin•4mo ago
the docs are on 1.8.17 and it's happenig there too
ryansolid
ryansolid•4mo ago
Hmm...
Jasmin
Jasmin•4mo ago
and on router 0.13
ryansolid
ryansolid•4mo ago
Ok.. I imagine it is still related to hydration cancellation but maybe we've had this issue longer than I thought. Hmm.. top level await not working is a Nitro issue their defaults are ancient and the expected override doesn't seem to work. However we did figure this out solve it months ago. I just don't remember where the setting was. You have to tell Nitro to use a higher target. I'd be surprised if the connection of effects was anything but incidental
Katja (katywings)
Katja (katywings)OP•4mo ago
for me its happening with everything on latest (just in case 😅)
ryansolid
ryansolid•4mo ago
Again reproduction would help
Katja (katywings)
Katja (katywings)OP•4mo ago
I'd love to make a simple one but failed so far 🙈
REEEEE
REEEEE•4mo ago
fwiw I only started noticing the issues after 1.8.19. I was on 1.8.19 for a while and then after upgrading I started noticing the issues
ryansolid
ryansolid•4mo ago
Yeah the change was in 1.8.20, and then a small fix in 1.8.21. Hydration cancellation is more aggressive now. I wonder if effects for previously hydrated parts are getting stranded somehow.
davedbase
davedbase•4mo ago
This seems to be a pretty pervasive issue. Seeing this in 3 projects now
ryansolid
ryansolid•4mo ago
My guess is the problem is here..
ryansolid
ryansolid•4mo ago
GitHub
solid/packages/solid/src/reactive/signal.ts at main · solidjs/solid
A declarative, efficient, and flexible JavaScript library for building user interfaces. - solidjs/solid
ryansolid
ryansolid•4mo ago
I have an idea of how to change it but it's just a guess without having a reproduction to play with.
davedbase
davedbase•4mo ago
Solid docs next has the issue. @Jasi provided details above
ryansolid
ryansolid•4mo ago
The idea of this code is to hold user effects until all lazy components had hydrated. Sort of a hack but things were a bit too disruptive before. I think the problem is it doesn't account for the fact that context might be getting cleared earlier..
davedbase
davedbase•4mo ago
Video demonstrating the issue
ryansolid
ryansolid•4mo ago
Yeah its possible this has existed for a while and only got more prevalent after we got more aggressive here with the router.
davedbase
davedbase•4mo ago
Creating a full repro seems to be challenging so we have to give examples of where they exist in actual implementations. I have another (private) codebase I can share with you demonstrating another if you can't find what you need in the docs example
ryansolid
ryansolid•4mo ago
Ok I can finally reproduce it.. I was having a hard time moving the mouse fast enough on reload. My internet is too fast, computer too powerful
davedbase
davedbase•4mo ago
I had the same issue. Throttling helped
ryansolid
ryansolid•4mo ago
Ok assuming I can get this going locally. I will debug tomorrow. I'm having such a hard time reproducing this I tried opening the stuff on stackblitz but it never loads.. gitpod loads but I can never seem to reproduce it I wonder if it is harder to trigger in dev I had to disable the search in all these environments because I don't have the profile so maybe its related to taht
REEEEE
REEEEE•4mo ago
I've noticed that a couple of the bugs aren't happening in dev but are in prod Not sure what exactly the issue is but certain interactions no longer work like opening a Kobalte dropdown is broken or context values aren't being found
Jasmin
Jasmin•4mo ago
oh true, I quickly tried to reproduce it with the solid docs in dev mode and didn't manage to
davedbase
davedbase•4mo ago
@REEEEE maybe we should get Ryan access if you can constantly reproduce it in Inv? I just got permission from Sam
REEEEE
REEEEE•4mo ago
Go for it
davedbase
davedbase•4mo ago
Will coordinate with Ryan in core
ryansolid
ryansolid•4mo ago
Yeah it could be related but its not the same issue I will see if I can debug the prod docs site ugh.. can't run it in replace because replay is some old fork of firefox that doesn't support Object.hasOwn Which is used in one of the library deps I'm going to just blind fix it. I know what the issue is. It might not fix all issues but I can fix the initial ones this way. ok 1.8.22
davedbase
davedbase•4mo ago
@REEEEE give it a spin
REEEEE
REEEEE•4mo ago
Testing... Seeing the same issue with the dropdowns
Jasmin
Jasmin•4mo ago
I can't figure out how to run the solid docs in prod mode locally lol. nitro just exists instantly after pnpm start
REEEEE
REEEEE•4mo ago
build without preset and then start? I ran into that just now and had to remove the preset
Jasmin
Jasmin•4mo ago
oh, I have preset = node currently
REEEEE
REEEEE•4mo ago
yeah it needs to be node-server or not set I tried node too
Jasmin
Jasmin•4mo ago
ohh thanks :zzz_flushedfroge: weird I can't even reproduce the bug locally with the old solid version
REEEEE
REEEEE•4mo ago
One thing I noticed with the dropdown issue is that it seems to rerender the trigger and children when I click it :pepegeHmm: I noticed the issues on our project are only in prod
Jasmin
Jasmin•4mo ago
I'm running prod locally
REEEEE
REEEEE•4mo ago
*prod deployed
Jasmin
Jasmin•4mo ago
ohh yeah weird, that seems to be the case here too
REEEEE
REEEEE•4mo ago
wait I might have a crazy theory /issue located @Jasi Can you try something really quick for the docs or I can I guess
Jasmin
Jasmin•4mo ago
if it takes 1 minute or less should be in bed
REEEEE
REEEEE•4mo ago
nix in the microwave? oh nvm then, have a good night
Jasmin
Jasmin•4mo ago
:cozycat: good night!
REEEEE
REEEEE•4mo ago
I'm still testing it but I seemed to have fixed the issue we were having on our project for the dropdowns by removing the children helper we were using to handle a function as children Testing on the docs site to see if it's related
ryansolid
ryansolid•4mo ago
Did this fix the docs? That was the one I was targetting Cause I could actually reproduce it there
REEEEE
REEEEE•4mo ago
I'm testing now with latest solid I can't reproduce it now with latest Solid (1.8.22) and removing the children helper https://deploy-preview-860--solid-docs.netlify.app/ this might also be related to issues with Switch/Match @ryansolid
Jasmin
Jasmin•4mo ago
why did you remove the helper? but it seems fixed!
Katja (katywings)
Katja (katywings)OP•4mo ago
From what I can tell so far, this fixed both of my issues 🥳
- the effects (including onMount) ran reliably in all 30 tries (tab reloads) - link hover during hydration doesn't break the app anymore I gonna deploy it to prod next and make there a couple more runs 🙂 Edit: still no issues, after further use throughout the afternoon 🎉
REEEEE
REEEEE•4mo ago
It wasn't working by just updating solid
Jasmin
Jasmin•4mo ago
hm so the bug is still there with that specific case?
REEEEE
REEEEE•4mo ago
Yeah I could be wrong but I downgraded solid on the project I'm working on to 1.8.18 and still had issues until I removed the children helper
Jasmin
Jasmin•4mo ago
yeah, the solid docs are on 1.8.17 currently the bug was there before the hydration changes it seems
ryansolid
ryansolid•4mo ago
Awesome
Joe Pea
Joe Pea•4mo ago
I'm still getting stuff not running. What I can confirm though is that if I make a small change to a file in dev mode, the HMR causes things to finally run and everything gets into place as expected. Its just the initial load not working, but after I've triggered HMR the app goes ahead and works fine. If I set ssr: false, no problem, so for now I've got a client-only app and technically I could just go without Solid Start altogether in this case.
Want results from more Discord servers?
Add your server