Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The serve command returns exit code 0 when compilation fails #230

Open
NiklasEi opened this issue Dec 30, 2023 · 4 comments
Open

The serve command returns exit code 0 when compilation fails #230

NiklasEi opened this issue Dec 30, 2023 · 4 comments

Comments

@NiklasEi
Copy link

I use the serve command to build a static site. It returns when all routes are "rendered". If compilation fails, cargo leptos serve returns 0, which causes issues in my CD pipeline.

Is there any reason for the command not to fail in this case?

@benwis
Copy link
Collaborator

benwis commented Dec 30, 2023 via email

@NiklasEi
Copy link
Author

The serve command actually does exactly what I need for static site generation. The name might not really fit, but the functionality is correct. It compiles the bin for the native target and the frontend for WASM. Then it runs the binary. For a SSR app the binary will start the actix/axum server. In the case of SSG, it will generate the html files of static routes.

This issue is really only about the return code of the command. Even if you use cargo leptos serve for a "normal" SSR app, and one of the two compilations fail, the command will return 0 instead of some error code.

@benwis
Copy link
Collaborator

benwis commented Dec 30, 2023

I should say that serve building the package is at best an oversight and at worst a bug, as serve really is only supposed to serve an existing binary. Is it possible to solve your use case by running build first to catch compilation errors, and then serve? Or is there another level of runtime errors you're hoping to catch around generation?

@NiklasEi
Copy link
Author

I expect serve to also build. Other tools do the same. trunk serve or cargo run also compile first if the project isn't compiled yet.

Running build before serve could be a work-around, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants