solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: `useAction` causes silent crash on the client

Open shoooe opened this issue 1 year ago • 5 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Current behavior 😯

  • Using useAction with non trivial server side code causes a silent crash on the client and no errors

Expected behavior 🤔

  • Using useAction with 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

shoooe avatar Dec 01 '24 14:12 shoooe

It's unclear what command I should run exactly for the "Your environment 🌎" section but I'm happy to oblige.

shoooe avatar Dec 01 '24 14:12 shoooe

i'm also experiencing this from time to time

jackbisceglia avatar Dec 15 '24 00:12 jackbisceglia

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 avatar Dec 17 '24 00:12 brenelz

@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.

jackbisceglia avatar Dec 17 '24 04:12 jackbisceglia

@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.

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.

atilafassina avatar Feb 12 '25 11:02 atilafassina