dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Bundled fullstack app for macOS crashes on server request

Open Sitin opened this issue 8 months ago • 5 comments

Problem

Default fullstack project crashes on server request when bundled for OS X.

Steps To Reproduce

Create a new project:

dx new test && cd test

Options:

  • ? 🤷 Which sub-template should be expanded? — anything
  • ? 🤷 Do you want to use Dioxus Fullstack?true
  • ? 🤷 Do you want to use Dioxus Router? — anything
  • ? 🤷 Do you want to use Tailwind CSS? — anything
  • ? 🤷 Which platform do you want DX to serve by default?Desktop

Fill [bundle] section in Dioxus.toml:

[bundle]
identifier = "com.mycompany"
publisher = "MyCompany"

Bundle application for macOS:

dx bundle --platform desktop \
    --package-types "macos" \
    --package-types "dmg"

Open application (directly or installed from the .dmg) and type anything in the ServerFn Echo input.

Application closes immediately.

Expected behavior

There should be an echo response from the server.

Environment:

  • Dioxus version: 0.6.3 (as resolved by Cargo and set in Cargo.lock)
  • Dioxus CLI version: 0.6.3 (via cargo-binstall)
  • Rust version: 1.85.0
  • OS info: macOS 15.2
  • App platform: desktop

Sitin avatar Mar 17 '25 12:03 Sitin

Looks like the fullstack template is not set up to start a server on desktop.

A possible workaround is to turn your "server" functions into normal functions on non-web targets by changing #[server] to #[cfg_attr(not(any(feature = "desktop", feature = "mobile")), server)] though. This only works for applications that don't need the client<->server split of course, but arguably it's a better default than starting a server unnecessarily.

neobrain avatar Mar 23 '25 14:03 neobrain

Your suggestion, @neobrain, makes sense. However, I've found another workaround: by bundling web platform after desktop. This gives me a properly working server part. Still not ideal and I hope that this issue will be fixed soon.

Sitin avatar Mar 23 '25 23:03 Sitin

This might be the same issue as https://github.com/DioxusLabs/dioxus/issues/3689 which https://github.com/DioxusLabs/dioxus/pull/3693 fixes. I do get a server bundle at /target/dx/test/release/web/server when I bundle desktop with the git version of the CLI, but that server bundle launches the desktop app

ealmloff avatar Mar 24 '25 12:03 ealmloff

Thanks, @ealmloff! I think there is a slight conceptual confusion introduced by docs and standard examples. The full-stack is good for web targets. Mobile and desktop apps in most of the cases do not need full-stack support. What they usually need is a proper backend.

For example, in my own project I've fixed the "issue" by removing server dependency from native apps (I've started with "workspace" template). Now, my server just serves and supports web, while all business logic that requires backend goes through tarpc (other people may choose something else).

So, this bug now almost looks like a feature to me.

Sitin avatar Mar 24 '25 20:03 Sitin

Now, my server just serves and supports web, while all business logic that requires backend goes through tarpc (other people may choose something else).

Fullstack is built for both web and native targets. On all platforms (including desktop), server functions should function like tarpc. If you are targeting web, it will also handle prerendering the html for better SEO. If you prefer a separate backend for desktop, you can use that instead. Server functions act as a remote function call on the server for both web and native targets.

ealmloff avatar Mar 24 '25 21:03 ealmloff