diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_12572.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_12572.rs index a107b354d159..35f056f8fa80 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_12572.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_12572.rs @@ -26,11 +26,7 @@ mod prisma_12572 { .to_owned() } - #[connector_test(exclude( - Postgres("pg.js.wasm", "neon.js.wasm"), - Sqlite("libsql.js.wasm"), - Vitess("planetscale.js.wasm") - ))] + #[connector_test] async fn all_generated_timestamps_are_the_same(runner: Runner) -> TestResult<()> { runner .query(r#"mutation { createOneTest1(data: {id:"one", test2s: { create: {id: "two"}}}) { id }}"#) diff --git a/query-engine/core/src/executor/request_context.rs b/query-engine/core/src/executor/request_context.rs index e4f0c7122ee9..17138f0cf214 100644 --- a/query-engine/core/src/executor/request_context.rs +++ b/query-engine/core/src/executor/request_context.rs @@ -1,5 +1,6 @@ use crate::protocol::EngineProtocol; use query_structure::PrismaValue; +use wasm_rs_dbg::dbg; #[derive(Debug)] struct RequestContext { @@ -18,14 +19,17 @@ tokio::task_local! { /// /// If we had a query context we carry for the entire lifetime of the query, it would belong there. pub(crate) fn get_request_now() -> PrismaValue { - // FIXME: we want to bypass task locals if this code is executed outside of a tokio context. As - // of this writing, it happens only in the query validation test suite. - // - // Eventually, this will go away when we have a plain query context reference we pass around. - if tokio::runtime::Handle::try_current().is_err() { - return PrismaValue::DateTime(chrono::Utc::now().into()); - } - REQUEST_CONTEXT.with(|rc| rc.request_now.clone()) + + REQUEST_CONTEXT + .try_with(|rc| rc.request_now.clone()) + .unwrap_or_else(|_| + // FIXME: we want to bypass task locals if this code is executed outside of a tokio context. As + // of this writing, it happens only in the query validation test suite. + // + // Eventually, this will go away when we have a plain query context reference we pass around. + // Skipping the branch for WASM since there we never have a running tokio runtime + PrismaValue::DateTime(chrono::Utc::now().into()) + ) } /// The engine protocol used for the whole duration of a request. @@ -47,6 +51,7 @@ where use chrono::{Duration, DurationRound}; let is_set = REQUEST_CONTEXT.try_with(|_| async {}).is_ok(); + dbg!(&is_set); if is_set { fut.await @@ -60,6 +65,7 @@ where request_now: PrismaValue::DateTime(dt.into()), engine_protocol, }; + dbg!(&dt); REQUEST_CONTEXT.scope(ctx, fut).await }