-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
seanaye/feat/js fetch #1554
seanaye/feat/js fetch #1554
Conversation
It looks like the CI is trying to compile the new example and its failing because the build step is different |
The changes made to the Axum integration here (removing
|
oh I thought that was being tested by CI and passing, my mistake. I'll add a cfg if block because creating the pool causes wasm to panic |
fixed |
@gbj I think I might need some help getting the CI to play nice with the new example. Something with the matrix of different features is causing cargo clippy to fail |
|
Okay, sorry it's taken me a long time to get to this. It turns out that my point 3 above was wrong: I have run my standard test for this and it seems to work fine, without leakage across runtimes, and without any modifications. I suspect it has to do with the JS/WASM environment being single-threaded in any case: is Deno spinning up additional threads and running different JS runtimes in them for different requests? The test, for future reference, and in case I screwed it up
I'm honestly not sure what's going on with the CI. Digging into it a bit. It has to do with the combo wasm+SSR combo and feature flags, I'm sure. |
No, Deno will not spin up worker threads by default but in theory it would be possible. The rust futures do get run via the JS event loop though so it is 'non-blocking' in a sense, for IO-bound operations at least. I think that as long as we aren't leaking the runtime then leptos has fulfilled its end of the bargain, it would be up to the caller to do worker threads if desired. This would be separate WASM instances so if 1 runtime doesn't leak then N runtimes also wont leak. Regardless, I think the main usecase for this PR is edge runtimes like Cloudflare Workers where threading is already abstracted away. |
ClearServerCount::register_explicit().unwrap(); | ||
AdjustServerCount::register_explicit().unwrap(); | ||
GetServerCount::register_explicit().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@9oelM Correct, automatic registration isn't and can't be supported on WASM targets, and unless I'm mistaken that's documented in the server function docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap got that thanks for the answer @gbj !!
@seanaye, the axum-js-fetch repo seems to be private, could you make it available? |
Yes of course, my mistake, I will do so later today |
@g2p https://github.com/seanaye/axum-js-fetch PRs are welcome |
What is this
This PR adds good-enough support for targeting the wasm32-unknown-unknown target on the server.
This opens up the door for deploying to edge platforms such as Cloudflare workers, Deno Deploy, Netlify Edge, etc.
Really anything that supports the standard fetch API and wasm
Still TODO (another PR)
figure out the integration with
cargo leptos
this is currently pretty roughUsage
cd examples/hackernews_js_fetch
deno task build
deno task start