fix(build): isolate hydrate feature to wasm32 target and prevent SSR spawn_local panic

This commit is contained in:
dahyeon committed 2026-11-04 23:24:19 +09:00
1 parent b43b060c8a
commit 6a157a2eca
4 files changed
+74 -4

No files matched your search

+71
View File
@@ -185,6 +185,77 @@ async fn serve_photo(State(pipeline): State<Pipeline>, Path(photo_id): Path<Stri
#[cfg(test)]
mod job_events_tests {
use super::*;
use axum::body::Body;
use axum::http::Request;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn ssr_routes_render_without_spawn_local_panic() {
std::env::set_var("LEPTOS_OUTPUT_NAME", "make-space");
let store = storage::Store::connect(&storage::StorageConfig {
mongodb_uri: "mongodb://127.0.0.1:1".into(),
mongodb_db: "test".into(),
minio_endpoint: "http://127.0.0.1:1".into(),
minio_access_key: String::new(),
minio_secret_key: String::new(),
minio_bucket: "test".into(),
})
.await
.expect("in-memory store fallback");
let llm = llm::LlmClient::new("http://127.0.0.1:1", "", "test-model");
let pipeline = Pipeline::new(
store,
llm,
pipeline::PipelineConfig {
kakao_api_key: String::new(),
ncp_client_id: String::new(),
ncp_client_secret: String::new(),
browser_scraper_url: None,
max_photos_per_source: 5,
max_photos_total: 10,
},
);
let conf = get_configuration(None).expect("leptos config");
let leptos_options = conf.leptos_options;
let routes = generate_route_list(app::App);
let pipe_for_ctx = pipeline.clone();
let _app_router: Router<()> = Router::new()
.route("/health/live", get(health_live))
.with_state(pipeline.clone())
.leptos_routes_with_context(
&leptos_options,
routes,
move || {
provide_context(pipe_for_ctx.clone());
},
{
let opts = leptos_options.clone();
move || app::shell(opts.clone())
},
)
.fallback(leptos_axum::file_and_error_handler(app::shell))
.with_state(leptos_options.clone());
for uri in ["/", "/?q=test", "/recent", "/place/kakao%3A1", "/nonexistent-404-path"] {
use axum::body::to_bytes;
let pipe = pipeline.clone();
let opts = leptos_options.clone();
let handler = leptos_axum::render_app_to_stream_with_context(
move || {
provide_context(pipe.clone());
},
move || app::shell(opts.clone()),
);
let req = Request::builder()
.uri(uri)
.header("Accept", "text/html")
.body(Body::empty())
.unwrap();
let resp = handler(req).await;
assert_eq!(resp.status(), StatusCode::OK);
let bytes = to_bytes(resp.into_body(), usize::MAX).await.unwrap();
assert!(!bytes.is_empty());
}
}
#[test]
fn missing_job_returns_a_terminal_error() {