framesurge / perseus

A state-driven web development framework for Rust with full support for server-side rendering and static generation.
https://framesurge.sh/perseus/en-US
MIT License
2.17k stars 90 forks source link

Cannot deploy a perseus app using beta.19 #259

Closed Miroito closed 1 year ago

Miroito commented 1 year ago

This issue is reporting a bug in the code of Perseus. Details of the scope will be available in issue labels. The author described their issue as follows:

Cannot deploy an app in the beta.19 due to missing item HSR_IGNORE on generic type S in functions of package perseus:

  • get_frozen_global_state_and_register
  • get_frozen_state_and_register

The steps to reproduce this issue are as follows:

I'm not sure whether my app has something special that makes the deployment fail. It might just fail trying to deploy any app.

A minimum reproducible example is available at <>.

Tribble internal data dHJpYmJsZS1yZXBvcnRlZCxDLWJ1ZyxBLWRlcGxveW1lbnQsYXV0aG9yLXdpbGxpbmctdG8taW1wbA==
Miroito commented 1 year ago

I'm willing to open a PR for this, I want to make sure I have the right idea because I didn't spend enough time in the project to understand what this code does. Here's my idea:

The trait MakeRx looks like this (without the doc comments):

pub trait MakeRx {
    type Rx: MakeUnrx;
    #[cfg(debug_assertions)]
    const HSR_IGNORE: bool = false;
    fn make_rx(self) -> Self::Rx;
}

Meaning HSR_IGNORE is available on types that implement the MakeRx trait only on debug builds.

But the functions get_frozen_state_and_register and get_frozen_global_state_and_register both have this condition:

if *is_hsr && S::HSR_IGNORE {
    return Ok(None);
}

Which has no guard to not be compiled in non-debug builds.

I would propose to simply guard either the full condition, or split it in order to prevent the compiler from tying to find HSR_IGNORE on non-debug builds. Or perhaps HSR_IGNORE should be defined on all builds and in this case we would just remove it from the trait definition.

Please let me know, I'm willing to open a PR if it is a simple change (again because of my light understanding of what is actually going on there) or feel free to fix it quickly.

PS; I'm surprised something like this would not be picked up while trying to build the library in release mode, I haven't tried though.

arctic-hen7 commented 1 year ago

Oh I'm an idiot, thank you very much, you're absolutely right. PR would be great! (I'll also check up on the CLI tests, which should have caught this...)