[Bug?]: `useAction` causes silent crash on the client
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
- Using
useActionwith non trivial server side code causes a silent crash on the client and no errors
Expected behavior 🤔
- Using
useActionwith server side code simply works
Steps to reproduce 🕹
Repro repo: https://github.com/shoooe/solid-start-blank-page
Context 🔦
I'm trying to call a server-only action using useAction
Your environment 🌎
No response
It's unclear what command I should run exactly for the "Your environment 🌎" section but I'm happy to oblige.
i'm also experiencing this from time to time
I did a bit of testing and its because your calling a function outside of "use server". I would think it should be able to handle it.
If you move "use server" to the top of the file it works
@brenelz I don't think the mode of failure is the concern on this (ie. there are a number of ways to repro this, this just happens to be one of them), but rather the way in which it's failing.
When this is happening in start, assuming the issues I've faced are the same as this, the error just basically nullifies the entire subtree from where it occurs, meanwhile the app continues running as expected above this level of the component tree. This creates an experience where a portion of your app fails to render with no insight as to why, other than the inferring the rough problematic route by what fails to render.
Thus, I don't think the specific 'use server' placement is the real concern here. It may solve this specific issue, but eg. I'm using start on a project with server: false set, and have experienced similar behavior when using actions on client. The common thread between this and the issues I've faced is the action method itself.
@brenelz I don't think the mode of failure is the concern on this (ie. there are a number of ways to repro this, this just happens to be one of them), but rather the way in which it's failing.
When this is happening in start, assuming the issues I've faced are the same as this, the error just basically nullifies the entire subtree from where it occurs, meanwhile the app continues running as expected above this level of the component tree. This creates an experience where a portion of your app fails to render with no insight as to why, other than the inferring the rough problematic route by what fails to render.
Thus, I don't think the specific 'use server' placement is the real concern here. It may solve this specific issue, but eg. I'm using start on a project with
server: falseset, and have experienced similar behavior when using actions on client. The common thread between this and the issues I've faced is theactionmethod itself.
The issue is only addressable within SolidStart if it's a treeshaking problem (which we have improved the heuristics in 1.1.0 - so I'm inclined to say the cases that are related to Start are mitigated).
If there are additional issues with action(), this is something we'll have to track in solid-router instead. So it would be super helpful if we knew these other different cases where this happen and could provide the team with a reproduction so perhaps action is patched there.