Replies: 1 comment 1 reply
-
The issue is that node.js assumes you're running a server that should only output hydratable HTML without any reactivity. You can work around that using https://github.com/atk/solid-register that I wrote for testing solid in other testing tools than jest or vitest. |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to use solid-js signals in nodejs and I'm realizing that it may not be supported. But I'm not sure since I can't find any explicit mention about this in the docs.
What I've observed is that createMemo returns stale values for signals when used in nodejs. I looked into the source code for the server implementation of createMutable and it seems like it indeed just uses the original value without initializing any reactivity. This would explain why memos then would return stale values, since it can't recognize anything to react to, so it will always return the initial value from when the memo was created.
It seems strange if it's intentional because it's a quite unintuitive behavior change. The following code snippet would work as expected and as documented in the browser, but when running it in node it simply behaves differently, as if solidjs is a different library with different rules when running it inside node:
When I found out that
createMutable
just returns the initial state as-is, I went to check ifcreateMemo
had a similar nodejs implementation to adjust the behavior. I was hoping that maybe in nodejs,createMemo
doesn't actually memoize, but instead just uses the function as-is, to align with the behavior change increateMutable
, but that wasn't the case.My primary question is basically if solidjs signals are supported in nodejs. But it would also be super interesting to hear more about the intent of the nodejs behavior change of
createMutable
, and possibly a response to whether my idea in the paragraph above would be something reasonable to implement to make nodejs behavior align with browser behavior.I made a small repro to demonstrate this issue:
https://stackblitz.com/edit/solid-node-stale-memo-values?file=main.ts
Appreciate any thoughts, thank you!
Beta Was this translation helpful? Give feedback.
All reactions